($ _SESSION [' cart '] PRODUCTS.
<form name="formulario2" method="POST" target="oculto"><input type="hidden" name="action" value="update">
foreach($_SESSION['cart'] as $product_id => $quantity) {
echo "<td align=\"center\"><input type = \"text\" size=\"1\" name=\"qty[$product_id]\" value =\"{$_SESSION['cart'][$product_id]}\"></td>";
}
</form>
次に、以下を使用して ($_SESSION['cart']) 数量を更新します
<?php
if(isset($_POST['action']) && ($_POST['action'] =='update')){
//
foreach ($_POST['qty'] as $product_id=> $quantity){
$qty = (int)$quantity;
if ($qty > 0){
$_SESSION['cart'][$product_id] = $qty;
}
}
}
?>
ここで、($_SESSION['cart']) に UPDATED した数量をデータベースの STOCK の数量に減算したいと思います 。
最後の "foreach ($_POST['qty']" では、更新された数量をデータベース数量から差し引く必要があると思いますが、その方法がわかりません。