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?? Quote Link to comment 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. Quote Link to comment 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' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.