Page 1 of 1
How to send a message to a specific logged in User.
Posted: Thu Nov 25, 2004 7:04 am
by asterinex
Hello,
I have the following problem :
I have a website where different users can log in. Some users can be friends of eachother.
for example if John is online and Frank (his friends) logs in . I want a tekst to appear only on John´s screen "Hey John ... Frank is online".
Anyone any suggestions how to do this ?
Thanks
Posted: Thu Nov 25, 2004 8:37 am
by MarK (CZ)
You'd have to store who's friend of whom in db and then something like:
Code: Select all
$sql = "SELECT users.name FROM users, friends ". // get names of active users
"WHERE users.time > '".(Time()-300)."' ". // only those who were active in past 5 minutes
"AND users.id = friends.friend_id ". // only those who are set as friends
"AND friends.user_id = '$userID'";
I hope I didn't make an error

Posted: Thu Nov 25, 2004 8:54 am
by asterinex
YO Thanks,
looks good.
Do you think you could put the code in a small frame with a auto-refresh?
Posted: Thu Nov 25, 2004 10:22 am
by MarK (CZ)
Why not
It's just important to log time of last user action to keep this info about online friends up-to-date (so not only logging of user's log-in but also other actions - otherwise user active for more than 10 minutes would act as inactive).
Posted: Fri Nov 26, 2004 2:40 am
by asterinex
OK, Gonna try it ?
One Question regarding performance.
How much requests can a SQL Database handle. If fe 500 USERS are online and each have an auto-refesh to query the database . Can de SQL Database handle such Traffic? What Problems can occur ?
Posted: Fri Nov 26, 2004 3:01 am
by Archy
Depends how often the page refreshes; it it were to refresh every one or two minutes, then it generally shouldnt be too bad on the database. Every 10 seconds may make the database strain a little bit if all those users were online.
Posted: Fri Nov 26, 2004 3:33 am
by asterinex
Ok thanks "Just a little bit" Sounds good ! I guess , I have to trie it out !
Thanks eveyone