【发布时间】:2009-10-26 19:28:48
【问题描述】:
您好,我想每 3 秒刷新一次我的 php,这就是我所拥有的:
<?php
session_start();
include "../config.php";
$time = time();
$sql1 = "UPDATE login SET lastlogin = '" .$time. "' WHERE id = '" .$_SESSION['userid']. "'";
$res1 = mysql_query($sql1) or die(mysql_error());
$onlinetime = "10"; // 10 seconds
$sql3 = "SELECT * FROM login ORDER BY lastlogin DESC";
$res3 = mysql_query($sql3);
while($row3 = mysql_fetch_array($res3)){
if($row3['lastlogin'] + $onlinetime > time()){
echo '<b><font color="green">✔</font></b> <u>'.$row3['name'].'</u><br />';
}else{
echo "<b><font color='red'>X</font></b> <u>".$row3['name']."</u><br />";
}
}
?>
这并不令人耳目一新,真的很烦人。它在我的聊天框中显示谁在线。有人帮忙吗?谢谢。
【问题讨论】: