2016-10-10 82 views
-1

这些是我的购物车页面上的代码。如果我更新数量,总价格将增加但不增加或减少。如何在我的购物车页面中更新我的更新数量?

<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>*/ 
+2

添加或减去什么?什么应该工作? –

+0

产品的数量。该用户从产品页面订购。如果客户想要更改数量。它会增加或减少。 – Michael

回答

0

你没有声明$ qty,而是在会话中赋值e-g $ _SESSION ['qty'] = $ qty; 你应该试试$ _SESSION ['qty'] = $ asd;

+0

好吧,我会尝试。谢谢。 – Michael

+0

标记接受的问题,如果你满意,谢谢 –

+0

它仍然不工作先生。 – Michael

0

上线你得到错误,改变这一行 $ check_pro = “从购物车中选择*其中ip_add = '$ IP' AND的p_id = '$ pro_id' 到 $ check_pro =” SELECT * FROM车哪里ip_add ='“。$ ip。”'AND p_id ='“。$ pro_id。”' as in single quotes u can not specify variables it it it string