0

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.

Edited by ~s.o.s~: moved to web dev

2
Contributors
1
Reply
9
Views
1 Year
Discussion Span
Last Post by stultuske
0

First of all: don't forget to add an actual question to your post, secondly, the code you show, is JavaScript, not Java.
A good first start is knowing what language you are working in.

Did you write this code yourself?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.