Hi Sirs,
I need to resolv this logic:
I have two tables: Table1 (where to pick-up name. one by one until at the last name to filter on Table2).
Table2 (This table will ONLY display during 5 seconds records filtered then will pass will display the filter of the next name from the Table1).
These codes are afected to filter records of Table2 inserting name manually into input. But I would love to see himself pick-up name one by one display the filtering action on Table2 until the last name from Table1
Table1
name year
______________
steve - 2026
kalamah - 2026
anderson - 2026
Table2 (where records will be filtered)
if(isset($_POST['search']))
{
include('testdb.php');
$valueToSearch = $_POST['valueToSearch'];
$query = "SELECT * FROM india_company WHERE name = '".$valueToSearch."'";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM india_company";
$search_result = filterTable($query);
}
function filterTable($query)
{
$connect = mysqli_connect("x","xx","xxx","xxx");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
Amira BedhiafiPosted Apr 14, 2026, 12:13 PM
Hello !
Why it is not working I think the issue is here: $_POST['valueToSearch']
that means someone must type the name and must click the button and I don't see any logic to read names from Table1 automatically
or remember which name is current and switch every 5 sec.
So instead, try to use PHP to get the current name from Table1 and JS to refresh every 5 sec with the next name and a prepared statement instead of this:
$query = "SELECT * FROM india_company WHERE name = '".$valueToSearch."'";
here is my solution you can adjust it for your need of course :