enigma1 Posted March 12, 2008 Share Posted March 12, 2008 Any help would be appreciated - if you can understand what i've done. I think it's a simple fix but just can't see it. This is my first post so please be gentle. I have 2 tables in mysql, tableA and tableB. TableA has the fields tableA_id and photo TableB has the fields tableB_id, tableA_id and TableA There is a relationship between the 2 tables and it's better shown if i use data. Data in TableA TableA_id 1 2 3 photo pic1 pic2 pic3 Data in TableB TableB_id 1 2 3 TableA_id 1 2 3 TableA 3 2 1 I am having trouble displaying the field in photo (TableA) from TableB. This is my php code: $tab_qry = $DB -> query(" SELECT b.*, a.photo FROM TableB AS b LEFT JOIN TableA AS a ON (a.TableA_id = b.TableA_id ) WHERE b.TableB_id = " . $TableB_id ); $tab = array(); while($ta = $DB -> fetch_array($tab_qry)){ $tab[] = $ta; } Link to comment https://forums.phpfreaks.com/topic/95791-help-displaying-field-in-table-1-from-table-2/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.