Assuming in PHP
file there're :
function printAllRows(){
for( everyrows in db){
echo "<tr>";
echo "<td> $_POST['..'] <td>";
echo "<td> $_POST['..'] <td>";
echo "<tr>";
}
}
function printSpecifRows($keyword){
.....
}
// When the page loads for the first time
if ($db->preRow() >0){ // count rows in DB , if there already show them as table
printAllRows();
}
At the same time , there is
<input type="text" name="keywoard" />
<input type="submit" name="find" value="search" />
If the user enter the keyword press the button , then just show the rows match the keyword!
so :
if( $_POST["find"]){
?>
<script>
// first clear the current DOM table
document.getElementById("myTable").innerHTML="";
</script>
<?php
// then print again! according to printSpecifRows($keyword)
function printSpecifRows($keyword){
.....
}}
But the problem here is that JS
is rendered first before PHP
, so printSpecifRows($keyword)
won't never be reached , any idea. I really appreciate your help. Thanks.