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
https://forums.phpfreaks.com/topic/201761-simple-db-array-question/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.