可能重复:
如何计算网站上的在线用户
如何关闭已关闭浏览器或选项卡的用户,并在他们返回到我的在线用户列表中的页面时将其重新打开?这是我的代码:
$sql = "SELECT
user_id,
user_name,
user_class,
online
FROM
users
WHERE
online = 1
GROUP BY
user_name ASC ";
$result = mysql_query($sql);
if(!$result)
{
echo 'There are currently no user online.' . mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{
echo 'There are currently no user online.';
}
else
{
//display category data
while($row = mysql_fetch_assoc($result))
{ $D= $row['online'];
if( ($D) !=1)
{
echo 'There are currently no user online.';
}
else
{
echo'<a href="/index.php?area=profile&userid=' . $row['user_id'] . '" ' . $row['user_class'] . '>' . $row['user_name'] . '</a>, ';}}}}?>