【发布时间】:2010-12-20 15:49:23
【问题描述】:
我们正在构建实时统计计数器,每 10 秒刷新一次数字。 (类似于stackoverflow问题计数器)。我们有简单的html页面,我们尝试嵌入php并尝试使用jquery,但没有成功。有什么帮助吗?谢谢
<html>
<script>
var auto_refresh = setInterval(
function() {
$('#stats').fadeOut('fast').fadeIn("fast");
},
10000
);
</script>
<div id="stats">
<?php
global $conn;
$query="SELECT count(*) as total FROM posts WHERE type='update'";
$query2="SELECT count(*) as total FROM members WHERE USERID>0";
$postnum = mysql_query($query);
$posts = mysql_result($postnum,0);
$chanid = mysql_query($query2);
$channels = mysql_result($chanid,0);
print "<div id='statnr'><h6> $channels </h6><h1>channels </h1> </div>";
print "<div id='statnr'><h6> $posts </h6><h1>posts </h1> </div>";
?>
</div>
</html>
【问题讨论】:
-
var_dump $conn、$postNum、$chanid 和 $channels 并在此处返回结果。