这些是我的购物车页面中的代码。如果我更新数量总价格相乘但不加或减。
<tr align="center">
<td> <button name="remove[]" onclick="returnshow_confirm();" value="<?php echo $prod_id; ?>">Remove </button></td>
<td><?php echo $prod_name; ?><br /> <img src="images/<?php echo $prod_image; ?>" width="60" height="60" /></td>
<td><input type="text" size="4" name = "qty" value = "" /></td>
<-- here are the part of update--->
<?php
if(isset($_POST['qty'])){
$asd = $_POST['qty'];
$update_qty = "update cart set qty = '$asd'";
$run_qty = mysqli_query($con, $update_qty);
$_SESSION['qty'] = $qty;
$total = $total*$qty;
echo "<script>windows.open('cart.php',_self)</script>";
}
<--- to here --->
?>
<td><?php echo "Php ".$single_price; ?></td>
</tr>*/
答案 0 :(得分:0)
你没有宣布$ qty但是在会话中分配e-g $ _SESSION ['qty'] = $ qty; 你应该尝试$ _SESSION ['qty'] = $ asd;
答案 1 :(得分:0)
您在哪一行收到错误并更改此行 $ check_pro =“select * from cart where ip_add ='$ ip'AND p_id ='$ pro_id' 至 $ check_pro =“select * from cart where ip_add ='”。$ ip。“'AND p_id ='”。$ pro_id。“' 如在单引号中你不能指定变量,它认为它是字符串