I am wanting to iterate through an array in POST, but my code is failing to enter the loop...
echo var_dump($_POST['pizza']);
foreach($_POST['pizza'] as $orderline) {
$number = 2;
echo "inside",
$query = "INSERT INTO orderlines (itemID,orderID,quantity) VALUES (?,?,?)";
$stmt = mysqli_prepare($DBC, $query); //prepare the query
mysqli_stmt_bind_param($stmt, 'sss', $orderline, $orderID, $number);
mysqli_stmt_execute($stmt);
echo mysqli_error($DBC);
mysqli_stmt_close($stmt);
}
The echo "inside" is just for debugging to show that I have got inside the loop, which I am not. The initial var_dump($_POST['pizza') is for debugging to see that there is infact an array with values. The array does exist, but the echo fails to execute; hence I am not inside the loop and I am failing to see why.
Much thanks