Question
Looping an array into a DB
| I am building a shopping cart web application based on the 3 part tutorial on here but I have found that the when adding the items of an order it looks through the whole array and saves it into one DB field and looses the quantity of each item and subtotal for each item. I need it so it loops through the array and saves item name, quantity and subtotal for each item in seperate DB rows. I was thinking I would need to change the DB fields to something like: itemname1 itemname2 itemname3 itemprice1 itemprice2 itemprice3 itemquantity1 itemquantity2 itemquantity3 itemtotal1 itemtotal2 itemtotal3 etc. Can anyone offer any help on how i can loop through the array to make it do this or if you have any other ways I can go about it? Thansk Lewis |
