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. Link to comment https://forums.phpfreaks.com/topic/201761-simple-db-array-question/ 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? Link to comment https://forums.phpfreaks.com/topic/201761-simple-db-array-question/#findComment-1058404 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? Link to comment https://forums.phpfreaks.com/topic/201761-simple-db-array-question/#findComment-1058409 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. Link to comment https://forums.phpfreaks.com/topic/201761-simple-db-array-question/#findComment-1059116 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 Link to comment https://forums.phpfreaks.com/topic/201761-simple-db-array-question/#findComment-1059154 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.