ahsesino Posted December 31, 2011 Share Posted December 31, 2011 Hello guys, I'm trying to figure out how to display and image that is located in one table (profile) and make it correspond to a variable on another table (latest_post) to where you echo out the variable from the table(latest_post) and the image from table(profile) appears next to the post. any how here is my code: <?php $query = mysql_fetch_array(mysql_query("SELECT person FROM latest_post AND avatar_img FROM profile WHERE id FROM latest_post = id FROM profile ")); echo $query['avatar_img']; ?> Also when echoing out the query I only get the name of the image and not the image this is most likely because my image is stored in a different folder right? Thanks in advance, your help is much appreciated since I'm barely a beginner at php and MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/254113-issues-displaying-one-image-from-2-tables/ Share on other sites More sharing options...
sasa Posted December 31, 2011 Share Posted December 31, 2011 something like this SELECT latest_post.person, profile.avatar_img FROM latest_post LEFTV JOIN profile ON latest_post.id = profile.id Quote Link to comment https://forums.phpfreaks.com/topic/254113-issues-displaying-one-image-from-2-tables/#findComment-1302773 Share on other sites More sharing options...
ahsesino Posted December 31, 2011 Author Share Posted December 31, 2011 Thanks for your reply sasa but that didn't work. I probable didn't explain my self right. I'll try again. 1. I need from table (latest_post) $post_id,$person and from table (profile) I need $nick,$avatar_img 2. I need $post_id,$person = $nick 3. Finally echo the avatar_img for that $nick Thanks again guys. Quote Link to comment https://forums.phpfreaks.com/topic/254113-issues-displaying-one-image-from-2-tables/#findComment-1302780 Share on other sites More sharing options...
ahsesino Posted January 2, 2012 Author Share Posted January 2, 2012 Hell again, I'm still banging my head trying to figure out the problem with my code, I did make some progress on it changing the query but the end result is not what I need. When echoing my query I should see the name of the avatar image but my result is an "S" below is the code I'm using: <?php $query = ("SELECT nick, avatar_img, person FROM latest_post, profile WHERE latest_post.person = profile.nick AND profile.nick = profile.avatar_img WHERE profile.avatar_img='$avatar_img'"); echo $query[$avatar_img]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/254113-issues-displaying-one-image-from-2-tables/#findComment-1303263 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.