deezy Posted December 4, 2008 Share Posted December 4, 2008 Hello! I have a php / mysql problem that I am struggling to find the best method for. The basic structure of my two tables is as follows: Selection id | Name | selections --------------------------- 1 | User1 | 12,16,22,34 2 | User2 | 2,17,66,69 Products id | Product | ------------- 4 | Prod1 | 5 | Prod2 | My page consists of a dropdown field (containing 'Name'), when a name is selected i need to use the php explode function to loop through the 'selections' and return the product names that the selected user has ordered. Is there a way to achieve this without adding any more tables as i really just need a quick fix. Thanks! Link to comment https://forums.phpfreaks.com/topic/135572-join-2-tables-based-on-dropdown-value/ Share on other sites More sharing options...
laPistola Posted December 4, 2008 Share Posted December 4, 2008 write a new mysql query for the selection and use the IN in the where clause eg WHERE product IN (" . $row['selections'] . ") by taking the string from selections directly into the brakets you dont need to explode. Link to comment https://forums.phpfreaks.com/topic/135572-join-2-tables-based-on-dropdown-value/#findComment-706331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.