Jump to content

Issues displaying one image from 2 tables


ahsesino

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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];
  
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.