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;
}
?>
Cynthia SathuragiriPosted Feb 12, 2026, 6:19 AM
PHP alone cannot do this because PHP runs only once per request.
To automatically change the filter every 5 seconds, you must use JavaScript (AJAX) along with PHP.
The idea is:
Get all names from Table1 (year = 2026)
Use JavaScript to loop through them
Send each name to PHP using AJAX
Display filtered results
Wait 5 seconds
Move to the next name
Stop when finished.
Step 1 – Create
get_names.phpThis file returns names from Table1 as JSON.
Step 2 – Modify
page_of_table2.phpThis file will receive a name and return filtered results.
(Note: Prepared statements are used to prevent SQL injection.)
Step 3 – Create the Main Page (Auto Filter Page)
What This Does
If Table1 contains:
steve
kalamah
anderson
The page will:
Show results for steve
Wait 5 seconds
Show results for kalamah
Wait 5 seconds
Show results for anderson
Stop automatically
No manual typing required.
Jignesh KumarPosted Feb 12, 2026, 5:36 AM
Hello Israel,
you can use this code and give a try,