Hi all.
I'm having a problem here. I want a script to search one field on a mysql database every 2 or 3 seconds. I need it to do this without reloading the page.
I've searched around and can't seem to find an answer. Tried using sleep(); function, but it's not working.
Here's what I tried so far:
Code:
//search the database:
$result = mysql_query("SELECT * FROM partidas WHERE id='$id_do_jogo' ",$connect);
$salazar = mysql_fetch_assoc($result);
//what's in the guest column?
$jogador_dois = $salazar['guest'];
//oh, nothing? than we...
while(is_null($jogador_dois)) {
//...print this out:
echo "<br>Column value is 0. Trying in another 2 seconds.";
//Wait 2 seconds and try again.
sleep(2);
}
//Or if it is NOT null:
echo "Value different from zero!";
exit();
Any ideas how I could get the script to print out the line "Column value is 0..." and then it tries looking at the database again?
Any help is welcome and apreciated.
|