<?php //Put your basic server info here $server = "localhost"; //normally localhost $db_user = "root"; //your MySQL database username $db_pass = "password"; //your MySQL database password $database = "users"; $timeoutseconds = 300; //it will delete all people which haven't refreshed(so probbably are // offline or inactive) in $timieoutseconds time (so it actually checks the people that are active in the last // $timeoutseconds seconds) //this is where PHP gets the time $timestamp = time(); //counts the timeout, all people which have been seen last online in earlier than this timestamp, will get removed $timeout = $timestamp-$timeoutseconds; //connect to database mysql_connect($server, $db_user); //add the timestamp from the user to the online list $insert = mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','".
PHP+MYSQL实例:网站在线人数的代码_网学