Home > php教程 > php手册 > body text

网站当前的在线人数

WBOY
Release: 2016-06-21 09:03:31
Original
945 people have browsed it
这是我的多用户统计的在线统计部分

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$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]; 
转自:动态网制作指南 www.knowsky.com



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template