PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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".
$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'";
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).
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 ?
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.