#SQL Products Clothing Table w/ Multiple Attributes

smimo

New Member
I am very new to MySql and PHP but I have designed three tables as shown below.Products:
ID | TITLE | BODY | PRICE | IMAGE
1 | shirt | text | 2.00 | na.jpg
2 | sweat | text | 2.00 | na.jpg
3 | pants | text | 2.00 | na.jpg
4 | lngsl | text | 2.00 | na.jpg
tshirt_color:
ID | COLOR | SIZE | IMAGE
1 | white | Small | 2.00 | na.jpg
1 | black | Small | 2.00 | na.jpg
1 | purple | Medium | 2.00 | na.jpg
2 | orange| Medium | 2.00 | na.jpg
tshirt_size:
ID | SIZE |
1 | XSmall |
1 | Small |
1 | Medium|
2 | Small|
2 | Medium|
Looking at these table's I have a few redundancies, such as size and color listed in all tables, because I cannot figure out the proper way to organize these tables.I have it set up so that you click on a product type (design) then you will see a picture of that product with a drop down box that allows you to pick a size. Only the sizes that are available to that product id#. For example product #1 is only in X-Small, Small & Medium.Once you click that I want to be able to choose only the colors that pertain to that particular size, from the tshirt_color table. For example Product #1 in Small is only available in black and white. How would I use "SELECT" to grab only that information, based off of the previous choice in the SMALL dropbox (which will post the info to the URL ie. http://website.com/index.php?id=1&size=small). I hoped to use the $_GET feature to grab that size and use it in the SELECT feature.Any ideas??Also if there is a better way to structure my tables I am open to that suggestion as well, been racking my brain at this for the past few days, and short of redoing all the tables just curious if it's possible.Thanks!
 
Top