list of users online in a members site...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
The-Master
Forum Commoner
Posts: 45
Joined: Sun Aug 07, 2005 9:51 am
Location: Israel

list of users online in a members site...

Post by The-Master »

hi, i want to make a list of users online on my site, but not the "there are X users online", i want to make a list of users online that are members of the site... the table of users is "users": "user" is the row with the users' nicks and ofcourse a "id" row for an id... (this is just like in phpBB stats on the forum's index)
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

make another table 'usersonline' with

Code: Select all

ID, userid, stamp
and when an user logs in, insert a record into usersonline with userid and current time(), when the user moves around the site, update the stamp field with current time().

to remove any loged out users, just do

Code: Select all

DELETE FROM usersonline  WHERE STAMP < 5 MINS ETC

to show, just

Code: Select all

select users.username from users,usersonline where users.id = usersonline.userid
good luck
Post Reply