Hey i had a question. A PHP code of mine isnt working right. I'm designing an e-commerce site for a candle store using a shopping cart. I have a database, two tables in this DB are Orders and Order_Items. Orders contains lists of orders and Order_Items contains details. Ex :- Order #49 contains 3 different types of candles. Order_Items would thus have have 3 entries for Order #49, one for each candle type together with the quantity and price of each. The problem is that my code enters the Order correctly in the database, but in Order_Items, only the first Order item is entered, the remaining are not. Here's the code that's doing both of these functions. Can anyone help me out here? How can I get all items inserted properly in the Order_Items table?
Here's the code for the Orders table --
$date = date('Y-m-d');
$query = "insert into Orders values
('', $customer_id, '$date', ".$HTTP_SESSION_VARS['total_price'].", 'SUBMITTED')";
$result = mysql_query($query);
if (!$result)
return false;
Here's the code for the Order_Items table
// insert each candle
foreach($HTTP_SESSION_VARS['cart'] as $candle_id => $quantity)
{
$detail = get_sizes_details($candle_id);
$query = "delete from order_items where
order_id = '$order_id' and candle_id = '$candle_id'";
$result = mysql_query($query);
$query = "insert into order_items values
('$order_id', '$candle_id', ".$detail['candle_price'].", '$quantity')";
$result = mysql_query($query);
// if(!$result)
// return false;
}