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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.