Home >Backend Development >PHP Tutorial >Ministry of Education Degree and Graduate Education Development Center website Current number of people online on the website

Ministry of Education Degree and Graduate Education Development Center website Current number of people online on the website

WBOY
WBOYOriginal
2016-07-29 08:33:301226browse

This 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 use this table
temp4 Login time
$onlinetime Maximum offline time in 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];

The above introduces the current online number of people on the Ministry of Education Degree and Graduate Education Development Center website, including the content of the Ministry of Education Degree and Graduate Education Development Center website. I hope it will be helpful to friends who are interested in PHP tutorials.

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