I have an array for a shopping cart which is set up like this:
$_SESSION['cart'][] = array("prodId" => $id,
"prodName" => $prod,
"prodSize" => $size,
"prodPrice" => $price,
"prodBrand" => $brand,
"prodQty" => 1);
I have a form which displays what's currently in the cart and an editable field for the quantity which the user can change.
My problem lies in editing the array to update the new quantity obtained from the form.
so far i have this:
if ($GET['action'] == "update") {
foreach($SESSION['cart'] as $items) {
$newQ = $_POST[$items["prodId"]];
if ($newQ == "" || $newQ == 0) {
$items["prodId"] = "";
}
elseif ($newQ > "0") {
$items["prodQty"] = $newQ;
}
}
}
$newQ contains the correct new quantity from the form but I can't update the array with the new value:
$items["prodQty"] = $newQ;
and
$items["prodId"] = "";