I am creating an ecommerce site.
At present I have a table called 'attribute_titles' like so:
ID NAME
1 size
2 colour
I then have a table called 'attribute_values' like so:
ID ATTRIBUTE_ID VALUE
1 1 small
2 1 medium
3 1 large
4 2 red
5 2 green
6 2 blue
Then my products table will include an array of attributes that apply to the product in question so size and colour would be ['1','2']. I then have a pricing table which has a price for each variation of the product with a multidimensional array for the attribute. So a small red product would have ['1'=>'1','2'=>'4'] as the attribute.
I have a drop down for size and a drop down for colour on my product page, but not all combinations might exist so for example we only have a green product in size medium and large.
Therefore if someone chooses green as the colour, then I want to update the dropdown so the size small isn't shown.
At present they can just select any colour or any size and then I check to see if that combination exists in my pricing table and if not I just have a warning, but I don't want them to be able to choose an option that doesn't exist.
Any ideas or suggestions on how I can achieve this would be greatly appreciated.