网站地图    收藏   

主页 > php专栏 > php综合实列 >

网站当前的在线人数-PHP实例

来源:自学PHP网    时间:2014-12-25 09:57 作者: 阅读:

[导读] 网站当前的在线人数,这是我的多用户统计的在线统计部分gb_temp表:temp1用户IDtemp2流览ip地址nbsp;nbsp;temp3online//做了个标记,因为其他功能也要使用这个表temp4登陆时间$onlinetime最长离线时...

这是我的多用户统计的在线统计部分

gb_temp表:
temp1 用户ID
temp2 流览ip地址  
temp3 online//做了个标记,因为其他功能也要使用这个表
temp4 登陆时间

$onlinetime最长离线时间分钟
db_class是我定义的一个数据库操作类。

///////////////////
//在线统计
$db = new db_class;
$db->connect();

$limit_time = time() - ($onlinetime * 60);
$online_time = time();

$db->query("delete from gb_temp where (temp4<$limit_time or temp2='$ip') and temp1='$id' and temp3='online'"); //删除离线$onlinetime分钟的用户
$db->query("insert into gb_temp (temp1,temp2,temp3,temp4) values ('$id','$ip','online','$online_time')");
$onres = $db->query("select count(*) from gb_temp where temp1='$id' and temp3='online'");
$onlineuser = $db->fetch_array($onres);
$onlineuser = $onlineuser[0]; 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论