Jump to content

Simple DB / Array Question


trichards

Recommended Posts

I am building a simple shopping cart.  I store my purchased items in my orders table as comma separated values.  Ex. (1,1,2,2,2).  The number coincides with product ID and frequency determines the quantity of the product.  I am interested in understanding how I can use this information to display:

 

(#Total Quantity of Each Product) Product Name

Ex. (3) Product Name

 

Thank you in advance.

Link to comment
Share on other sites

Sorry, my question was jumbled.

 

What I was saying that instead of storing a string in the table with the numbed of item numbers indicating how many were ordered, just create a table as follows:

 

product_id, num_ordered

 

All you have to do then is to increment the num_ordered for each particular item when an order is placed.

 

To find out how many of an item were ordered, just to a query on that particular item number.

 

if you post your script and table structure, I can help you better.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.