Hello. First off here is the code: <? include("include.php"); $result = mysql_query("SELECT * FROM friends WHERE `of` = '$logged[username]'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['friend']; echo "<br />"; $friends = $row['friend']; $result2 = mysql_query("SELECT * FROM users WHERE `username` = '$friends'") or die(mysql_error()); } while($row2 = mysql_fetch_array($result2)) { echo $row2['lname']. " - ". $row2['fname']. " - ". $row2['username']; echo "<br />"; } ?> PHP: The problem is row2 only returns anything if row finds only 1 friend. So I am guessing that the query of $row[friend] is merging all results instead of keeping them as for example "Dwight" "Josh" "Thomas" (separate) that it is putting them as "Dwight Josh Thomas" of course, this is not a result in the users table The idea is that it finds the name from the one table then goes to the users table for the rest of that users information such as first name, last name and avatar etc. If you don't understand, I will rexplain. Thank You.
<? include("include.php"); $result = mysql_query("SELECT * FROM friends WHERE `of` = '$logged[username]'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['friend']; echo "<br />"; $friends = $row['friend']; $result2 = mysql_query("SELECT * FROM users WHERE `username` = '$friends'") or die(mysql_error()); while($row2 = mysql_fetch_array($result2)) { echo $row2['lname']. " - ". $row2['fname']. " - ". $row2['username']; echo "<br />"; } } ?> PHP: u can try this?
personally i would use a join for something like this. <?php //connect shit here $sql = "select username, friend, avatar, url left join users on users.username = friends.friend where of = '".$logged['username']."'"; $result = mysql_query($sql); while ( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) { // echo data } ?> PHP: