這是我的多使用者統計的線上統計部分
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];
http://www.bkjia.com/PHPjc/315769.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/315769.htmlTechArticle這是我的多使用者統計的線上統計部分 gb_temp表: temp1 使用者ID temp2 流覽IP地址 temp3 online//做了個標記,因為其他功能也要使用這個表 temp4 登陸...