Jump to content

list online users, order by names asc


squiblo

Recommended Posts

The following code is what I have already done, but I have just realised that the way I have done this will not enable me to display the online users in alphabetical order, I do not know a way how to do this. Any help or suggestions?

 

Thanks

 

$friend_query = mysql_query("SELECT * FROM friend_request WHERE user='{$user_id}'");
$friend_id_array = "";
while($row = mysql_fetch_assoc($friend_query))
{
$friend_id = $row['friend_id'];
$more_query = mysql_query("SELECT * FROM friend_request WHERE friend_id='{$user_id}'");

while($row_more = mysql_fetch_assoc($more_query))
{
	$more_friend_id = $row_more['user'];
	//all friends in an array
	$friend_id_array = $friend_id_array.$friend_id."/".$more_friend_id;


	$friend_id_array = explode('/', $friend_id_array);
	$friend_count = count($friend_id_array);

	//how many of the friends are online
	$online_count = 0;
	for($i=0;$i<$friend_count;$i++)
	{
	$query_online = mysql_query("SELECT loggedin, fname, mname, lname FROM users WHERE id='{$friend_id_array[$i]}'"); //get loggedin and names
	$row = mysql_fetch_assoc($query_online);
	$loggedin = $row['loggedin'];
	if($loggedin == "1") //if logged in
		{
	$online_count++; // final number off people online
		}
	}
}
}

 

Link to comment
https://forums.phpfreaks.com/topic/214776-list-online-users-order-by-names-asc/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.