In a php page script (friends.php) I need to query two tables. One is "friends" table and the other is "members" table.
In a first query, I use:
$sql = mysql_query("SELECT * FROM friends WHERE (requesting_id=$id OR requested_id=$id) AND connect_type='1'");
while($row = mysql_fetch_array($sql)) {
$friend_id1 = $row[requesting_id];
$friend_id2 = $row[requested_id];
if($friend_id1 != $id){
$true_friend = $row[requesting_id];
} else {
$true_friend = $row[requested_id];
}
To select all rows where two members are friends, which stores them into a variable $true_friend.
Now, what I want to do, is grab the $true_friend's (id, firstname, and lastname) from my "members" table, so that I can display a list of the member's friends, using:
$outputList .= '
<table width="100%">
<tr>
<td width="13%" rowspan="2"><div style=" height:50px; overflow:hidden;"><a href="profile.php?id=' . $id . '" target="_self">' . $user_pic . '</a></div></td>
<td width="14%" class="style7"><div align="right">Name:</div></td>
<td width="73%"><a href="profile.php?id=' . $id . '" target="_self">' . $firstname . ' ' . $lastname . '</a> </td>
</tr>
</table>
<hr />';
So How would I set up the query for the member table, for each value of $true_friend...?