lpeek
05-29-2008, 03:29 PM
Hey!
Im setting up a 'Friends and Family' list type thing, and i know there will be certain people with the same surname...
What i want to do is get data from a mysql database and sort it by surname, the only thing is, that the table im getting the data from only contains the users id, and another table contains their surname.
What would be a good way to basically:
get the data from the first table and place each $result['id'] into a new array, lets just say $array then i would use that array when selecting from the next table to get the surnames...
I know 'how' to do it in theory, but im not sure on the coding to use.
something like this:
$result = mysql_query("SELECT * FROM table WHERE category=3");
$result_array = mysql_fetch_array($result);
// then here get the $result_array['id'] of every result and place it in a new variable called $array
$newresult = mysql_query("SELECT * FROM users WHERE id=$array ORDER BY surname ASC")
i think you get the idea...
any thoughts?
Many thanks.
Im setting up a 'Friends and Family' list type thing, and i know there will be certain people with the same surname...
What i want to do is get data from a mysql database and sort it by surname, the only thing is, that the table im getting the data from only contains the users id, and another table contains their surname.
What would be a good way to basically:
get the data from the first table and place each $result['id'] into a new array, lets just say $array then i would use that array when selecting from the next table to get the surnames...
I know 'how' to do it in theory, but im not sure on the coding to use.
something like this:
$result = mysql_query("SELECT * FROM table WHERE category=3");
$result_array = mysql_fetch_array($result);
// then here get the $result_array['id'] of every result and place it in a new variable called $array
$newresult = mysql_query("SELECT * FROM users WHERE id=$array ORDER BY surname ASC")
i think you get the idea...
any thoughts?
Many thanks.