Jump to content

Get users from db in alphabetical order


liamoco

Recommended Posts

I have a string which is a list of user id's like "44/5/6/67/7/88/56/76/9/90/65/74/8/68". I explode this string and put them into an array, but now I have a problem of getting the users first names from the database by using the id's and putting them in alphabetical order. How can I do this?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/214845-get-users-from-db-in-alphabetical-order/
Share on other sites

This is what I am trying...

 

$friend_id_array = $friend_id_array.$friend_id."/".$more_friend_id;
$friend_id_array = explode('/', $friend_id_array);

$query_online = mysql_query("SELECT loggedin, fname, mname, lname FROM users WHERE id in ('" . implode("'/'", $friend_id_array) . "' ORDER BY fname"); //get loggedin and names LINE 162
		while($row = mysql_fetch_assoc($query_online))
		{
			$loggedin = $row['loggedin'];
			$fname = $row['fname'];

			if($loggedin == "1")
				$online_count++;
		}

 

I cannot see what I am doing wrong, i have commented out to show line 162 in the code above

Fatal error: Call to undefined function impode() in J:\mowes\www\squiblo\functions.php on line 162

 

@ken, i noticed as soon as i posted it, ive change it, but still not working, im getting this error, although i have double checked all the field names are correct...

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in J:\mowes\www\squiblo\functions.php on line 163

 

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.