Ok, so I have a headech from searching everywhere on how to solve this problem. I'm trying to show online users, but not all users, only those on your friends list.
So, I have a table called users_online, and when a user logs in to my website in this table, 1 row is automatically created with the date, ip, name, user_id and friend_array (where all friends of friends are saved)
So, for example, I enter my site and a row is created in the users_online table. I want to see only my friends on the Internet, and these friends are stored in the friend_array column (1,5,16,5 (this is the identifier number of friends)). How can I take data from col_ru__ru_ru and find out which of these identifiers is registered? at the moment, what means which of these identifiers exists in the user_online table and is displayed in my profile?
Hope this is not a confusing question ...
Well, this is my code ... everything is stored in the online.php file:
// Checking wheter the visitor is already marked as being online: $inDB = mysql_query("SELECT user_id FROM users_online WHERE user_id=".$userid); if(!mysql_num_rows($inDB)) { // Selects some data required to insert into users_online table from users table $DB = mysql_query("SELECT img,fname,friend_array FROM users WHERE user_id=".$userid); while($row=mysql_fetch_assoc($DB)) { $img = $row['img']; $fname = $row['fname']; $farray = $row['friend_array']; } mysql_query(" INSERT INTO users_online (user_id,ip,img,fname,friend_array) VALUES(".$userid.",'".$intIp."','".$img."','".$fname."','".$farray."')"); } else { // If the visitor is already online, just update the dt value of the row: mysql_query("UPDATE users_online SET dt=NOW() WHERE user_id=".$userid); } // Counting all the online visitors: // Thats where i need to work out with friend array.. // I need to display all online friends only list($totalOnline) = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users_online")); // Outputting the number as plain text: echo $totalOnline;