I have searched this on google and this forum and and struggling to figure this out.
I have a table:
| id | fruit_name |
The id column is not unique i have several identical enstries and the name is also not unique and has several identical entries:
| 1 | apple |
| 2 | banana |
| 2 | apple |
| 1 | orange |
| 3 | grapefruit |
| 3 | apple |
| 1 | banana |
| 2 | peach |
| 3 | peach |
I have a multiple select list with the id="fruit" and using join to create a variable for my query:
$fruit_type = join("','",$_POST['fruit']);
$fruit_results = $conn->query("SELECT * FROM fruit WHERE fruit_name IN ('$fruit_type ')");
while($row = $fruit_results ->fetch_assoc()) {
echo $row['id'];
}
This is giving me all the id of any row that has any type of fruit that is selected in the list. I am trying to the id's that contain all of the fruit selected not just one or the others. Can anyone help me out please?
Thanks,
Halisco