I have an ecommerce store I am setting up and I need every item purchased entered in the database. For example, someone purchases a qty of 2, I need to repeat the SQL data entry so it has two entries. See code below and let me know how I can use product_qty to achieve this.
if (isset($_SESSION["cart_products"]))
{
$total = 0; //set initial total value
$b = 0; //var for zebra stripe table
foreach ($_SESSION["cart_products"] as $cart_itm)
{
$product_name = $cart_itm["product_name"];
$product_qty = $cart_itm["product_qty"];
$product_price = $cart_itm["product_price"];
$product_code = $cart_itm["product_code"];
$product_color = $cart_itm["product_color"];
$subtotal = ($product_price * $product_qty); //calculate Price x Qty
$name = $_SESSION['firstName']. ' ' .$_SESSION['lastName'];
mysqli_query(
$mysqli,
"INSERT INTO Order_Tickets
(sku, tktproduct, tktprice, purchaser)
VALUES ('$product_code','$product_name','$product_price','$name')"
) or die(mysqli_error());
}
}