i am trying to filter multiple products from database using php. i have check box in html page with 4 category,the values will be stored in a array on submit values post to php page , where data is filtered. see below example.
bellow is my html
<input class="le-checkbox" type="checkbox" name="filter1[]" value="<?=$bkey?>" /> <label><?=$bkey?></label>
<input class="le-checkbox" type="checkbox" name="filter2[]" value="<?=$bkey?>" /> <label><?=$bkey?></label>
<input class="le-checkbox" type="checkbox" name="filter3[]" value="<?=$bkey?>" /> <label><?=$bkey?></label>
<input class="le-checkbox" type="checkbox" name="filter4[]" value="<?=$bkey?>" /> <label><?=$bkey?></label>
values are stored in filter1[],filter2[],filter3[],filter4[]
in php
$filter1=$_POST['filter1'];
$filter2=$_POST['filter2'];
$filter3=$_POST['filter3'];
and also implode
i
f(isset($filter1)){
$pbrand= implode(",",$filter1);
}
if(!empty($filter2)){
$pcolor= implode(",",$filter2);
}
if(!empty($filter3)){
$pfab= implode(",", $filter3);
}
now check with mysql
$result = $dbh->prepare("SELECT * FROM products_list WHERE status='Available' AND brand IN (?) OR color IN (?) OR fabric IN (?)");
//$result->bindValue(1, $status);
$result->bindValue(1, $pbrand);
$result->bindValue(2, $pcolor);
$result->bindValue(3, $pfab);
its working fine when i select single checkbox from each category. when i check multiple checkbox from single catagory, its not working and also my condition status='Available'
not working i don't understand why its not working