This is my first contribution here:
So I am using PHP and MySQLi. I have a search bar and it works great, but I want to entries to disappear when I clear the search.
Using the search bar is changing the URL:
without search: http://localhost:52694/index.php
with search: http://localhost:52694/index.php?search=test
If I clear my search bar, it is still the same URL (http://localhost:52694/index.php?search=test
) and I cant click go
because it tells me that the box can't be empty to start search.
I hope everything is clear and you understand my issue.
This is my search in php code:
<?php
if(isset($_GET['search'])){
$filtervalues = $_GET['search'];
$query = "SELECT * FROM table WHERE CONCAT( value, name, zla ) LIKE '%$filtervalues%' ";
$query_run = mysqli_query($con, $query);
if(mysqli_num_rows($query_run) > 0) {
foreach($query_run as $items) {
?>
<tr>
<td><?= $items['value']; ?></td>
<td><?= $items['name']; ?></td>
<td><?= $items['zla']; ?></td>
<td>
<a class='btn btn-danger btn-sm' href='/delete.php?id=<?php echo $items['id']; ?>'>Del</a>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="4">No Record Found</td>
</tr>
<?php
}
}
?>