How to start a jQuery function after executing all the MySQL queries in that PHP page?
<p>I have a JavaScript timer function which contains a jQuery  function, and the JS function is called for every 3000 milliseconds.</p>

<pre><code>&lt;script type="text/javascript"&gt;
      function timer(){ $("div#display_time").load("timer.php");}

     var t=setInterval("timer()",30000);
&lt;/script&gt;
</code></pre>

<p>Inside the body tag I have some MySQL update queries. I am triggering this by using <code>onload</code> attribute to the <code>body</code> tag,
but these queries are not getting executed before the function is called.</p>

<pre><code>&lt;body onload="timer()"&gt;
&lt;?php
........................
.......................
 //here we will be using o,o,o,7,7,2011 as the standard of our time...
 $t=((time())-(gmmktime(0,0,0,7,7,2011)));
     $sql="UPDATE users
         SET
         user_level=1,
         current_qno=1,
         start_time=".$t.
      "WHERE user_id=".htmlentities($_SESSION['user_id']);
      $result=mysql_query($sql);
 if(!$result)
 {
    echo'&lt;p&gt;some thing went wrong' .mysql_error(). '&lt;/p&gt;';
 }   
 $_SESSION['user_level']=1;
 **echo'&lt;div id="display_time" "&gt;&lt;/div&gt;';**
</code></pre>
