trichards Posted May 14, 2010 Share Posted May 14, 2010 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. Quote Link to comment Share on other sites More sharing options...
siric Posted May 14, 2010 Share Posted May 14, 2010 Why would you know create a an entry in the table for each product code and store the amount ordered there? Quote Link to comment Share on other sites More sharing options...
trichards Posted May 14, 2010 Author Share Posted May 14, 2010 I not sure what your asking... I am trying to determine for each order what products we're purchased and how many. Can this be done using my product id succession? If not, how should I store the data in the database? Quote Link to comment Share on other sites More sharing options...
siric Posted May 16, 2010 Share Posted May 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
trichards Posted May 16, 2010 Author Share Posted May 16, 2010 That's actually great help. I was definitely thinking about this backwards. I can take it from here, thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.