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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.