如何使用相同的方法通过 foreach 循环发送多个字段值ID
?
这段 HTML 代码有什么问题?
<input type="text" size="3" name="new_quantity[<?php echo $product_id; ?>]" value="<?php echo $product_quantity; ?>" />
<input type="text" name="totalcost[<?php echo $product_id; ?>]" value="<?php $total_cost; ?>" />
现在PHP
代码
foreach($_REQUEST['new_quantity'] as $key => $quantity) {
foreach($_REQUEST['totalcost'] as $key => $total) {
$sql=mysql_query("UPDATE `categories`.`carts` SET `product_quantity` = '$quantity', `product_totalcost` = '$total' WHERE `carts`.`product_id` ='$key' AND cart_session='$sessionID'");
}
}