I have this array:
$filter=['color*black','color*blue','color*red','paint*apex','paint*dalton'];
Each value in $filter
has two substrings separated by *
. The first substring represents a database table column and the second represents a desired value for that column.
My products
table looks like this:
id name color paint
1 p1 black compo
2 p2 red dalton
3 p3 pink apex
4 p4 blue apex
5 p5 cream compo
Using $filter
, I need to search the products
table and return all rows with a paint
value of apex
or dalton
AND a color
value of black
, blue
, or red
.
The desired output is a mysql query that will only return these rows:
id name color paint
2 p2 red dalton
4 p4 blue apex