我怎样才能让计数自行刷新。目前我将它设置在一个页面上,我正在使用带有元刷新标记的Iframe,但我正试图摆脱iframe。
<?php $stmt = $db->prepare ("SELECT COUNT(*)AS rows_cnt FROM requests WHERE User=:user AND status='Received' AND Date=CAST(GETDATE() AS DATE) ORDER BY id DESC");
$stmt->execute(array(':user' => $user2));
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{ echo $row['rows_cnt'];
} ?>
答案 0 :(得分:0)
这里是你如何完成自动刷新div的小例子
Js:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script>
var auto_refresh = setInterval(
function ()
{
$('#divtoload').load('pagetoberefreshed.html').fadeIn("slow");//place html or php page that you want to be loaded into div
}, 50000); // refresh every 50000 milliseconds
</script>
html:
<div id="divtoload">
loading....</div>