I have a 2-fields form to select both category and supplier of some products:
<input type="checkbox" name="category[]" value="<?php echo $categories_id?>"/>
<input type="checkbox" name="supplier[]" value="<?php echo $produttori_id?>"/>
Many categories and suppliers are available in a WHILE loop.
In the submitted page, I've created those two loops to get all the selected category and supplier:
if(!empty($_POST['category'])) {
foreach($_POST['category'] as $check) {
echo $check;
echo "<br>";
}
}
and:
if(!empty($_POST['supplier'])) {
foreach($_POST['supplier'] as $check) {
echo $check;
echo "<br>";
}
}
Now I have to do a query to selects only records that are included in both arrays:
SELECT * FROM PRODUCTS WHERE supplier [is in the supplier array] AND category [is in the category array]
How can I achieve this?