I bring all users online:
$result = mysql_query("SELECT * FROM users "); while ($row = mysql_fetch_array($result)){ echo "<br>"; echo $row['username']; } And how now to update this list?
I bring all users online:
$result = mysql_query("SELECT * FROM users "); while ($row = mysql_fetch_array($result)){ echo "<br>"; echo $row['username']; } And how now to update this list?
there must be fields in the Users table: 1. online - the field responds to the user in the game or not (1 in the game, 0 in the game) 2. location - a link to the location where the user was last marked.
Then a request to select all users in a specific location is such "SELECT * FROM Users WHERE online = 1 and location =". $ Location
Broadcast a function to a timer that every 5, 10, 20 minutes (as you like) sends an Ajax request to the script and displays all users of this lock.
If a user leaves the game, then update his field in the table Users online = 0. If the user has moved to another loco, update the location field for this user, and then immediately make a request for all users in this locale.
Kk so
The easiest way is to use jquery + ajax + setInterval (setTimeOut)
Source: https://ru.stackoverflow.com/questions/42867/
All Articles