ok the3 above does not work, gives me the following error "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:...."
However I got it run with:
Code: Select all
public function getSelectedFriends(){
//$sql = 'select display_name from users where user_id = '.$this->user_id;
$sql = 'SELECT f.friend_id, u.first_name, u.last_name
FROM user_friends AS f
JOIN users AS u ON f.friend_id = u.user_id
WHERE f.user_id = '. $this->user_id;
$results = mysql_query($sql);
$friends = array(); // array
while($row = mysql_fetch_array($results)){
$friends[] = $row['first_name']. ' '. $row['last_name'];
}
return $friends;
}
This runs fine and it gives the correct information just not in the correct order. Its displaying the data in numerical order
eg if I select Peter Pan I get the following output:
User known as: Peter Pan
Friends with Pollen Ndlanya // user_id 3
Friends with Kaizer Motaung // user_5
Return
which is correct, however when I select Elvis Presley I get the following:
User known as: King of Rock
Friends with Peter Pan // user_id 1
Friends with Kaizer Motaung // user_id 5
Return
which is the right information but its not in the required order. I want it to look like this:
User known as: King of Rock
Friends with Kaizer Motaung // user_id 5
Friends with Peter Pan // user_id 1
Return
I do not want it to display in numerical order but rather the order in which is set in the DB in the user_friends table...can you help with this please?