Update Query with Loop
I am trying to update multiple recordsets on submit. The first insert works correctly but, nothing after that works. Thanks
Here is my code:
<?php
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
if ($customers->getColumnVal("delivery_allowed") == 'N') {
$type = 'Pickup'; }
$delivery_date = htmlspecialchars($_POST['delivery_date']);
if ($customers->getColumnVal("delivery_allowed") == 'Y' or $customers->getColumnVal("delivery_allowed") == NULL) {
$type = htmlspecialchars($_POST['type']);}
$InsertQuery = new WA_MySQLi_Query($old_mule);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "orders";
$InsertQuery->bindColumn("customerID", "i", "".((isset($customerID))?$customerID:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("date_submitted", "s", "".((isset($today))?$today:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("type", "s", "".((isset($type))?$type:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("delivery_date", "t", "".((isset($delivery_date))?$delivery_date:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("orderID");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
$orderID = $_SESSION['orderID'];
$status = 'Order Placed';
foreach($_POST['cartID'] as $cartID2) {
$UpdateQuery = new WA_MySQLi_Query($old_mule);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "cart";
$UpdateQuery->bindColumn("orderID", "i", "".((isset($orderID))?$orderID:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("status", "s", "".((isset($status))?$status:"") ."", "WA_DEFAULT");
$UpdateQuery->addFilter("cartID", "=", "i", "".($cartID2) ."");
$UpdateQuery->execute();
}
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>


