phppup Posted February 17, 2012 Share Posted February 17, 2012 As long as I'm logged in (although this may be more to the topic of 'table structure'), my table has fields for small, medium, and large blue candles and small, medium, and large pink candles. When an order is placed, the quantity requested is INSERTED into the correct field. Am I creating unnecessary overhead? Is there a way to have just one field for blue candles and one for pink, whereby the INSERT will record a customer request for 4 candles that are the small size? And how would I retrieve the data when I want to know both the total number of candles and their sizes. Note: the order form has radio buttons for the sizes, so a single order can only accept a single size per submission. Not sure if there's a simple way around that, but I'm learning more each day. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/257216-small-medium-large-with-quantities/ Share on other sites More sharing options...
requinix Posted February 17, 2012 Share Posted February 17, 2012 How about this structure? orders order_id | ... ---------+---- 1 | 2 | 3 | products product_id | color | size | ... -----------+-------+--------+---- 1 | blue | small | 2 | blue | medium | 3 | blue | large | 4 | pink | small | 5 | pink | medium | 6 | pink | large | orders_products order_id | product_id | quantity | ... ---------+------------+----------+---- 1 | 1 | 3 | 1 | 3 | 3 | 2 | 2 | 5 | 2 | 5 | 5 | That's a fairly typical setup for this kind of thing. Quote Link to comment https://forums.phpfreaks.com/topic/257216-small-medium-large-with-quantities/#findComment-1318509 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.