Jump to content

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

 

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.