runnerjp Posted April 14, 2009 Share Posted April 14, 2009 how could i join these 2 querys $result1=mysql_query ("SELECT friendname FROM friends WHERE username='Admin' ORDER BY friendname"); $myrow1 = mysql_fetch_array ($result); $friendname=$myrow1[friendname]; $result=mysql_query ("SELECT image FROM users WHERE friendname='$friendname'"); //loop statement while ($myrow = mysql_fetch_array ($result)) { // this is the column 1 if ($column == 1) { printf("<tr><td><b></b>%s</td>",$myrow[image]); } else{ //this is the column 2 printf("<td><b></b>%s</td></tr>",$myrow[image]); } //increment the count $count += 1; // this is a modulus operator it gets the remainder of the equation $column = $count % 2; } ?> so then i can echo out image?? Link to comment https://forums.phpfreaks.com/topic/154053-solved-how-to-join-2-querys/ Share on other sites More sharing options...
taquitosensei Posted April 14, 2009 Share Posted April 14, 2009 select friends.friendname,users.image from friends JOIN users where users.friendname=friendname.friendname order by friendname if it's possible that a user won't have an image then instead of JOIN you would use LEFT JOIN would return an empty field for user. Link to comment https://forums.phpfreaks.com/topic/154053-solved-how-to-join-2-querys/#findComment-809812 Share on other sites More sharing options...
runnerjp Posted April 14, 2009 Author Share Posted April 14, 2009 select friends.friendname,users.image from friends JOIN users where users.friendname=friendname.friendname order by friendname but where do u find out what the username='Admin' Link to comment https://forums.phpfreaks.com/topic/154053-solved-how-to-join-2-querys/#findComment-809823 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.