I wanna see if a value in a table has changed in a loop. there is a 60 second timer and while it counts it keeps checking if the table changed. here is the code:
setTimeout(function(x){return function(){
clabel.innerHTML = "Waiting " + x.toString() + "/ 60 seconds. Checker is "+ c;
c = checkdb();
if(c == 2){
window.location = "http://www.google.com";
}
};}(i), 1000*i);
function checkdb(){
return <?php
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare('SELECT * FROM game');
$stmt->execute(array('gameID' => $gameID));
$check->execute();
$r = $check->fetchColumn(1);
$conn = null;
echo $r;
?>;
when i change the table while the counter is going , the page does not get redirected. even though when i manually check the table the value does change there.