Forum Moderators: coopster
1. store the number in file on the server. Onload increment it, on exit decrement. However this way isn't very good (if the connection fails you have no idea that user is not logged in).
2. store the logged status in db. If user logs in then change his status to on and store time of login. If the user logs out then status is off. Change the status if user is on for more than an hour doing nothing.
SELECT COUNT(*) WHERE status='on'; This will give you number of logged users, or you can even print them out.
Best regards
Michal Cibor
Using HTML/PHP, a page is requested and downloaded, then nothing happens until another page is requested. So the best you can do is find out "how many people viewed a page in the last n minutes".
Set up an include that gets run on every page then script something like this.
$sql = "INSERT INTO `activity_table` (tcpip, time, pagename) VALUES ('".$_SERVER['REMOTE_ADDR']."', NOW(), '".$_SERVER['PHP_SELF']."');";
$result = mysql_query("$sql", $linkID);
This would log the tcp/ip address, time, and pagename into your database. Then, to see what's been entered in like the last 15 minutes you could use something like:
$sql = "SELECT * FROM `activity_table` WHERE time >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)";
$result = mysql_query("$sql", $linkID);
This is really simplified, but hopefully the concept helps.
Burner