我有一個JavaScript定時器函數,它包含一個jQuery函數,並且每3000毫秒調用JS函數。如何在執行PHP頁面中的所有MySQL查詢後啓動jQuery函數?
<script type="text/javascript">
function timer(){ $("div#display_time").load("timer.php");}
var t=setInterval("timer()",30000);
</script>
在body標籤中,我有一些MySQL更新查詢。我通過使用onload
屬性body
標記, 來觸發此操作,但是在調用該函數之前,這些查詢沒有得到執行。
<body onload="timer()">
<?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'<p>some thing went wrong' .mysql_error(). '</p>';
}
$_SESSION['user_level']=1;
**echo'<div id="display_time" "></div>';**
所有查詢都是在頁面加載到客戶端之前執行的。 – zerkms
您的查詢在服務器端完成。所以即使在頁面加載之前它也會被執行。那真的是什麼問題?錯誤? – Ibu
沒有表沒有得到更新... –