Hi, I’m having trouble filtering my table in php, it gives an error “The link on the referring page seems to be wrong or outdated” below is my code. Can you tell me what am i missing.
<?php
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
$query ="SELECT * FROM daily_data2 WHERE CONCAT(`Userid`, `Name`, `Campaign`, `Date`, `Hoursworked`, `Overtime`) LIKE '%".$valueToSearch."%'";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM daily_data2";
$search_result = filterTable($query);
}
function filterTable($query)
{
$connect = mysqli_connect("localhost", "root", "","bio_db");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<html>
<head>
<title>Employee Logs</title>
<style>
table,tr,th,td
{
border: 1px solid black;
}
</style>
</head>
<body>
<h2 align="center">Time and Attendance Monitoring</h2>
<center>
<form action="php_html_table_data_filter.php" method="post">
<input type="text" name="valueToSearch" placeholder="Value To Search"><br><br>
<input type="submit" name="search" value="Filter"><br><br>
</center>
<table align="center" width="600" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Userid</th>
<th>Name</th>
<th>Campaign</th>
<th>Date</th>
<th>Hoursworked</th>
<th>Overtime</th>
</tr>
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['Userid'];?></td>
<td><?php echo $row['Name'];?></td>
<td><?php echo $row['Campaign'];?></td>
<td><?php echo $row['Date'];?></td>
<td><?php echo $row['Hoursworked'];?></td>
<td><?php echo $row['Overtime'];?></td>
</tr>
<?php endwhile;?>
</table>
</form>
</body>
</html>