Jump to content

Showing results from one table where id matches another


darrenwindle

Recommended Posts

Hi, Im trying to show an image url on a page. The situation is I have 2 tables in my database

events table

Event_id

Event_name

Event_notes

img_id

Image table

img_id

img_path

I want it to show on specified events the img_path but cant as every time ive tried it shows just the one imge. I have many rows in both tables but need to select the relevant img_path from the 2nd table where the id matches the id from the first table.

Heres what I hacve got so far.

<?php 
     $sqlimg = "SELECT pd_events.img_id, pd_images.id, pd_images.pd_path, FROM pd_events, pd_images WHERE pd_events.img_id=pd_images.id"; 
     $resultimg = mysql_query($sqlimg) or die(mysql_error());
     while ($rowimg = mysql_fetch_array($result)) { 
     echo  $rowimg['pd_path'];
     }
     ?>
     <?php echo $row['eve_notes'];?></strong></p>

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.