告诉我谁和多少用户在线的脚本 [英] script to tell me who, and how many users, are online

查看:67
本文介绍了告诉我谁和多少用户在线的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的研究中,找到一种使PHP告诉我网站上有多少人在线"的方法,我发现有一些方法可以估计"这一点.

In my research to find a way to make PHP tell me how many people are 'online' on my site I've discovered that there are ways to 'estimate' this.

出于错误管理的考虑,我选择记录网站上发生的所有事情,但现在我只能编写SQL查询.

I've chosen to log everything that happens on the site, also for error-management sake, but now i'm stuck at writing my SQL query.

基本上,我有一个包含"IP","userid"和"datetime"的数据库,我发现这样的查询可以解决问题:

Basicly I have a database with 'IP', 'userid' and 'datetime' and I figured that a query like this would do the trick:

SELECT distinct(IP), datetime 
FROM `bigBrother` 
WHERE datetime BETWEEN DATE_SUB(NOW(), INTERVAL 3 MINUTE) AND NOW()

问题在于,我的网站通常是由学校网络上的学生查看和使用的,而且...他们的IP都相同.

The problem is that my site is mostly viewed and used by students on the school network, and well... they all have the same IP.

问题是,我这样做是否正确,是否可以从数据库中选择两个不同的行,以便对已注册的用户进行排序(谁将拥有"userid",其他人将具有userid = 0) ?

So the question is, am I doing this right, and can I select two distinct rows from my database, so that I can sort out the registered users (who will have a 'userid' - others will have userid = 0)?

推荐答案

只需使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆