So first of all I know there is many post about "How to store arrays in MySql database?" and yes I went through most of them and these solutions seems to just create separate tables and joins them. I do not think this is the case. At least I could not come up with anything.
Alright so I have following tables:
- product: |id|name|link|color_list|size_list|cloth_type|
- size_indicators |id|name|link|
- color_indicator |id|name|link|
- cloth_indicator |id|name|link|
What i want to do:
On the product page I have a filter with cloth_type, color, size.
Those are checkboxes.
I want to be able to check those boxes and press the "Filter" button or any other button to filter the query. I did not post already existing query because they are joining with other tables regarding other functions than this.
I was thinking maybe it is possible to have something like this:
size_indicators
table have string/array: 1,4,3
(something similar for other tables) so array would be $size_array([0] => 1, [1] => 4, [2] => 3)
and query would be like:
$stmt = $pdo->prepare("SELECT products.p_id, products.name, products.size_list, FROM products WHERE size_list = $size_array;
I know this query wont work, that was just an idea if i could somehow put array into product table on size_list
column and then compare it with array of sizes selected.
Help me to get general idea how I should do this for one list(size_list) and I will do the rest. I have been searching for this but cant really find anything that would help. Also mby I'm doing everything wrong and someone has other idea how I should construct my tables and do this.