[英]how to see how many users are online using epoch time?
i am having problem of see who's online and don't have any idea how to see who's online.what i am doing is updating mysql database using time(); 我有一个问题,看看谁在线,不知道如何看看谁在线。我在做什么是使用time()更新mysql数据库。 whenever user log in or refreshes the page. 每当用户登录或刷新页面时。
Then, lastactivity gets filled with epochtime for eg : 1387806657 or 1287373415. After that i select the lastactivity from database and use this condition but nothing happens. 然后,lastactivity充满了epochtime,例如:1387806657或1287373415。之后,我从数据库中选择了lastactivity并使用此条件,但没有任何反应。
<?
$result = mysql_query("SELECT lastactivity FROM users WHERE lastactivity!=0");
while($rahul = mysql_fetch_assoc($result)){
$last = $rahul['lastactivity'];
echo $last;
}
?>
</br>
<?
if ($result < time()-3600)
{
$hello = mysql_num_rows($result);
echo $hello;
}
else
{
echo "ERROR!";
}
?>
You could decide that any acticity in a 30 second interval from now means "online" 您可以确定,从现在开始的30秒间隔内的任何合理性都意味着“在线”
$early = time()-30;
$res = mysql_query("SELECT username,lastactivity FROM users WHERE lastactivity > $early") or die( mysql_error() );
while( $row = mysql_fetch_array($res) )
{
echo $row['username'].' is online.<br>';
}
转到源并解析或查看Apache日志以查看正在加载哪些页面,该如何做?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.