darrenwindle Posted June 7, 2012 Share Posted June 7, 2012 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 https://forums.phpfreaks.com/topic/263811-showing-results-from-one-table-where-id-matches-another/ Share on other sites More sharing options...
Barand Posted June 7, 2012 Share Posted June 7, 2012 I don't see how you get anything. Your resultset is "resultimg" yet you use "mysql_fetch_array($result)" Link to comment https://forums.phpfreaks.com/topic/263811-showing-results-from-one-table-where-id-matches-another/#findComment-1351992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.