php - Why doesnt my session array reads out properly?
one text
Solution:
Your query string is being set with the default null values of $orderID
, $productID
, etc. You have to remake that query each time. Put the entire query line inside your for loop.
...
$Quantity = $values["item_quantity"];
$query2 = "INSERT INTO orderdetails (OrderID, productID, UnitPrice, Quantity) VALUES ($orderID, $productID, $UnitPrice, $Quantity)";
mysqli_query($conn, $query2);
...
With that said, SQL Injection is a thing. Use prepared statements.
Source