tags:

views:

19

answers:

1

I am using a PHP Compoment, that accepts an ItemID and Return the Product Price.

Now I have to Change the component so that

the product may have a Standard Size or May Have Multiple Size.

For example

Watch has Standard (No Size) but Shoes May have Sizes like 5,6,7,.... And Depending on the Sizes the prices are also different.

What should be the best way to solve this Issue.

+1  A: 

Two ways come to mind:

1) Add a 2nd table/array that has ItemID / Size / Price and query that

ItemID  Item
1        Watch
2        Shirt

ID ItemID Size Price
1   1       0  14.95
2   2       S   9.95
3   2       M  10.95

2) Have multiple entries per ItemID in a single table/array ( at that point ItemID won't be able to be a primary key/array index/etc ) if an item has multiple sizes Example:

ID  ItemID  Item    Size Price
1   1       Watch   0   14.95
2   2       Shirt   S    9.95
3   2       Shirt   M   10.95

Generally speaking solution #1 is probably your best bet.

Rob