Question : Price modifier in a dropdown using PHP & MySQL

I have set up a basic CMS system using PHP & MySQL

I have one product table with all the detail page columns ie name, price, size, description etc.

I need to create a function so my client can add different sizes which have different prices. ie small - 10.00, medium - 20.00, large - 30.00

How would i work this with MQL?

I have managed to set up an option to select different sizes by sending comma delimited value to the table ie "small,medium,large" which then fills the dropdown menu using the explode function. My problem is linking these sizes to the relevant price.

Should i use the explode function for 'prices' too? so i submit small,medium,large to the size column and 10.00,20.00,30.00 to the price column then 'explode them into the option and value fields of the dropdown?

Is there a better way?





Answer : Price modifier in a dropdown using PHP & MySQL

OK, I think I understand better now.  I would add rows and maybe add columns to the data base.  Rows are definitely needed because there are more inventory items than there are rows in the way it stands now.  That is not a good thing.

Have a look at key #73, Angel Necklace.  You have two values in the price and size columns.  Data bases do not work right when you do things like that!  Each column-and-row intersection must contain one and only one value.

So if the Angel Necklace can come in two lengths, you need two rows for the data.  One row has the data including size and price for the 45cm model and the other row has the data for the 110cm model.  These are two different products, and the data base should reflect that fact.

To the instant issue... I would copy these rows, perhaps by using phpMyAdmin, and manually correct the data fields.  In the table maintenance script that is part of the CMS, you may need to add fields or otherwise revise the way that script accumulates the information about the products.

Best regards, ~Ray
Random Solutions  
 
programming4us programming4us