Forum Moderators: coopster
I'm TRYING to find a script that I can incorperate into my already existing tables that will allow me to pull who is online and how many like this (I need it for my archive of writing):
Who's Online: Moonbrat, Admin
Guests Online: 12
Members Online: 2
But I can't seem to find any. All of them are saying I'd basically have to destroy the login/signup script I have (which I DON'T want to do because all my members have encrypted passwords in my MySQL and there's too many to redo) and others only give one 1 username which is like: welcome (username) to....
Which is something I DON'T want either.
Can anyone suggest what I can do?
So far I have two scripts that do:
First: Total Online: 14
Second: 1 User registered in the past 24 hours: Moonbrat
I'm sorry to be such a pain in the rear-end.
-MB
You could just add a query at the top of the script. Since you just want to log it, you don't even need to display it. So...
- query for all users who have made a request in the last X minutes
- then run through the result set and store it in your archive in the desired format.
Let us know if you need more guidance than that.
Tom
No, it would get all users. Let's say you have a table with the following columns
userid name last_login
1 Qautle 2004-10-21 12:00:00
2 Phlamro 2004-11-21 12:00:00
3 Marok 2004-11-21 12:00:00
$q = "SELECT name FROM users
WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= last_login";
$result = mysql_query($q);
while($user = mysql_fetch_array($result))
{
$user_string .= $user['name'] . ", ";
}
echo substr($user string, 0, -2) // strip off last , and space.
That outputs a list of all users online. If you want to log it, I don't know how you want the data to look and how you want to log it, but that's roughlyhow you'd go about it.