JSHINER Posted April 27, 2007 Share Posted April 27, 2007 I have the following: function getListings($db, $zip= false) { $arr = $db->getArray("SELECT * FROM listing_table WHERE ZIP_CODE = '$zip' ORDER BY price DESC"); return $arr; } $page['listing'] = getListings($db, $_GET['zip']); foreach ($page['listing'] as $z) { echo .... And it returns everything fine. However, some fields in the listing_table define something as "H9595595" and in another table, lets call it member_table, that "H9595595" could be used to get their name, address, etc. So my question is, how can I get those two tables to communicate so in the foreach I can also return corresponding member information. So instead of returning "Field 1, Field 2, H9595595" if would return "Field 1, Field 2, John Smith" Link to comment https://forums.phpfreaks.com/topic/48951-solved-help-with-joining-two-tables/ Share on other sites More sharing options...
The Little Guy Posted April 27, 2007 Share Posted April 27, 2007 Try something like this: SELECT * FROM listing_table, member_table WHERE member_table.ZIP_CODE = '$zip' AND member_table.member_id = listing_table.member_id ORDER BY listing_table.price DESC Link to comment https://forums.phpfreaks.com/topic/48951-solved-help-with-joining-two-tables/#findComment-239825 Share on other sites More sharing options...
JSHINER Posted April 27, 2007 Author Share Posted April 27, 2007 Worked perfect, thank you. Link to comment https://forums.phpfreaks.com/topic/48951-solved-help-with-joining-two-tables/#findComment-239880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.