I have a field in the database that says ‘category’ its values are: ‘1,2,3,4’. I use ajax to select a category to output a product from the database. But I can not successfully extract the data from the database because I can not compare the data I send with those from this field.
The field in the database: category = 1,2,3,4
The data I select by ajax and compare it with this field: $_POST['category'] = 1,2
I try to compare them with the following code:
if ($_POST['category']!="") {
$cat_filter = implode(",", $_POST['category']);
$sqlProducts[] = "( category IN('".$cat_filter."'))";
}
I also tried with FIND_IN_SET