Home >Backend Development >PHP Tutorial >The current number of people online on the website_PHP tutorial

The current number of people online on the website_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:05:10919browse

This is the online statistics part of my multi-user statistics

gb_temp table:
temp1 User ID
temp2 Browsing IP address
temp3 online//I marked it because other functions are also To use this table
temp4 login time

$onlinetime longest offline time minutes
db_class is a database operation class I defined.

////////////////////
//Online Statistics
$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'"); //Delete users who are offline for $onlinetime minutes
$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.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315769.htmlTechArticleThis is the online statistics part of my multi-user statistics gb_temp table: temp1 user ID temp2 browsing IP address temp3 online //Made a mark because other functions also need to use this table temp4 to log in...
Statement:
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