This code works perfectly to update one OrderIn_ID, or one orderOut_id, it sets the paid column to Yes, and then goes to a page that displays those results. But if I order more than one orderIn_id, or more than one orderOut_id, it will only update the first one, and all other ID records remain at No. Should I use a case switch or a while loop to grab all order ID's contained in the order invoice. I know this is subject to SQL injections, it is a first semester school project and we have not learned PDO's at this point. I don't get any errors, just will not update more than one record of orderIn_id or orderOut_id. This is the php code that is called when pay this invoice is pressed. Can it update more than one record at a time, and can it insert into invoice table more than one orderIn_id or orderOut_id?
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_SESSION['orderIn'])) {
$orderIn_id = $_SESSION['orderIn'];
$orderIn_paid = "Yes";
$changeVal="UPDATE order_instate
SET orderIn_paid = '$orderIn_paid'
WHERE orderIn_id = '$orderIn_id'; " ;
$changeCheck=mysqli_query($dbhandle, $changeVal)
or die(mysqli_error($dbhandle));
}
if(isset($_SESSION['orderOut'])) {
$orderOut_id = $_SESSION['orderOut'];
$orderOut_paid = "Yes";
$changeVal2="UPDATE order_outstate
SET orderOut_paid = '$orderOut_paid'
WHERE orderOut_id = '$orderOut_id'; " ;
$changeCheck2=mysqli_query($dbhandle, $changeVal2)
or die(mysqli_error($dbhandle));
}
$invoice_total = 0;
$invoice_total = $gtotal;
$invoice_shipped = "No";
$shipped_date = "0000-00-00";
$add ="INSERT INTO invoice(user_id, orderIn_id, orderOut_id, invoice_total, invoice_shipped, shipped_date)
VALUES ('$user_id', '$orderIn_id', '$orderOut_id', '$invoice_total', '$invoice_shipped', '$shipped_date')";
$addCheck=mysqli_query($dbhandle, $add)
or die(mysqli_error($dbhandle));
if($addCheck != NULL) {
header("location: userOrders.php");
mysqli_free_result ($displayResult);
}
}
?>