in reply to Re: Re: Re: Need duplicate item entries in shopping cart
in thread Need duplicate item entries in shopping cart

Hi Perrin,

I understand what you're trying to tell me. I think my solution will have to be with the database structure. I don't want the script to loop through all the items all the time. I believe a lot of processing time would be required to run the script.

So, I'm going to investigate the database option. From your earlier reply to the node you mentioned a higher entity.

Here's an example of the database structures and let me see if I understand what you're trying to suggest.

Product Table:
item_id: 7
description: ball
category: toys
price: 5.69
PRIMARY KEY item_id

Color Table:
color_id: 7br
item_id: 7
color: blue

color_id: 7gr
item_id: 7
color: green

color_id: 7or
item_id: 7
color: orange

PRIMARY KEY color_id
FOREIGN KEY item_id

I would write a SQL that would join these two tables, along the lines:

SELECT product.item_id, product.description, product.category, product.price, color.color WHERE product.item_id = color.color_id GROUP BY product.item_id, product.description, product.category, product.price;

If I'm on the right track thus far, will I have a popup menu with the individual colors for a single item as well as be able to choose that item more than once with a different color?

Here's my online catalog:

Item picture, item description, item price,
a popup menu that will show me the colors: blue, green orange for this item.
To get a better idea, please visit: http://www.summitwebcrafters.com/cgi-bin/pet_shop1.cgi

Click on the Toys category and the first item on the page is the item that has colors at the moment.

With the above database structure, will I be able to achieve the look and feel of that Toys page, with the color popup menu, and the ability to add that same item with two different colors?

Do you think I'm on the right track?
  • Comment on Re: Re: Re: Re: Need duplicate item entries in shopping cart

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Need duplicate item entries in shopping cart
by perrin (Chancellor) on Feb 20, 2003 at 18:09 UTC
    That's not quite what I meant. I was thinking that every color of an item would have a unique item_id, so the blue sweater would be item_id 7 and the red version of the SAME sweater would be item_id 8. Then you would tie the related ones together with another table that links items 7 and 8 as part of the same "product" to be displayed on one page.