My database have this record:
timer_id = 1
time = 498
utc = 16:46:21
I'm retrieving the record the time column in the database but it won't retrieve the current record. I have this code for retrieving it:
function start(){
div = "<?php $select = mysql_query('SELECT COUNT(*) AS num FROM tbl_timer',$connection); while($row = mysql_fetch_array($select)){ $num = $row['num']; } ?>";
var num = "<?php echo $num; ?>";
alert(num);
if(num == 0)
{
document.getElementById("form1").innerHTML = '<input id="time1" onChange="alert('Hallo')" value="720"/>';
}
if(num !== '0')
{
var div = "<?php $select = mysql_query('SELECT COUNT(*) AS nu FROM tbl_timer',$connection); while($row = mysql_fetch_array($select)){ $nu = $row['nu']; } if($nu !== '0'){$select = mysql_query('SELECT * FROM tbl_timer',$connection); while($row = mysql_fetch_array($select)){ $time = $row['time']; $tc = $row['utc']; }}else{$time = 0; $tc= 0;} ?>";
var time = "<?php echo $time; ?>";
alert(time);
document.getElementById("form1").innerHTML = '<input id="time" value="'+time+'"/>';
document.getElementById("h").innerHTML = ' <button id="pt" onclick="pause()">Pause</button>';
secondPassed();
}
}
Whenever I alert the 'time' the output will be the previous record which is 510. What will I do to get the current record every time it will be stored in the database.