Pee-H-Pee
04-09-2006, 05:01 AM
I am trying to add a row into my database for each item my customers purchase. The code I have below works as long as there is only one item purchased. But if there are more than one it only adds the first item.
I know there has to be a foreach function in there somewhere and that is where I get lost.
I use SecureNetShop shopping cart:
Each item's name, description, price and quantity are posted in the following format:
item1=name~price~quantity
item2=name~price~quantity and so on...
// Insert ordered items into items table
list($order_num, $item_name, $item_price, $item_qty) =
split("~", $item1);
mysql_query("INSERT into items
(inv_num, item_name, item_qty, item_price)
VALUES
('$inv_num','$item_name', '$item_qty', '$item_price')");
I know there has to be a foreach function in there somewhere and that is where I get lost.
I use SecureNetShop shopping cart:
Each item's name, description, price and quantity are posted in the following format:
item1=name~price~quantity
item2=name~price~quantity and so on...
// Insert ordered items into items table
list($order_num, $item_name, $item_price, $item_qty) =
split("~", $item1);
mysql_query("INSERT into items
(inv_num, item_name, item_qty, item_price)
VALUES
('$inv_num','$item_name', '$item_qty', '$item_price')");