I want to filter the products that have size Like S, M, L
This table is a product table
id | size
------------
1 | S,M
2 | S,M,L
3 | S
4 | M,L
This is the Shirtsize database structure:
id | size
------------
1 | S
2 | M
3 | L
I have SQL problem to get these values.
if(isset($_POST["size"]))
{
$size_filter = implode('|', $_POST["size"]);
$s = implode(',', $_POST["size"]);
echo $query .= ' AND size rlike "^'.($size_filter).'" AND size like('%".$s."%')';
// $query .= 'AND size like('%".$s."%')';
}
I used this SQL query it's working in PHPMyAdmin but product no displayed in the frontend
SELECT * FROM products WHERE status = '1' AND size rlike "^M" OR size like('%M%')
SELECT * FROM products WHERE status = '1' AND size rlike "^M|L" OR size like('%M|L%')
This query working only in PHPMyAdmin but use that in localhost frontend got this error
Warning : A non-numeric value encountered in C:\xampp\htdocs\DU\fetch_data.php on line 28
Warning : A non-numeric value encountered in C:\xampp\htdocs\DU\fetch_data.php on line 28
Fatal error : Uncaught DivisionByZeroError: Modulo by zero in C:\xampp\htdocs\DU\fetch_data.php:28 Stack trace: #0 {main} thrown in