Last Updated: November 17, 2017
· husnain00789

I'm facing problem with my ecommerce cms cart page i need help anyone.

The problem is when i change the quantity of product and click to update cart my price update correctly but quantity come back to first quantity. For example if quantity is written 2 in cart page and i change it to 4 or 6 etc. and then when i click update cart everything done correctly except quantity the quantity again come back to 2 . i hope you understand.

there is my codes of cart page


include 'includes/head.php';
include 'functions/functions.php';
include 'includes/navigation.php';
include 'includes/searchbar.php';

<div class="container">
<form action="cart.php" method="post" enctype="multipart/form-data">
<h1 style="padding:30px">Your Shopping Cart</h1>
<div class="table-responsive">

<table style="border: 1px solid rgba(0,0,0,.1); border-radius:20px;" class="table border">
<th>Product picture</th>

    $total = 0;

global $con;
$ip = getIp();
$selprice = "select * from cart where ipadd= '$ip'";
$runprice = mysqliquery($con, $selprice);
price = mysqlifetcharray($runprice)){
id = $pprice['pid'];
$proprice = "select * from products where productid = '$proid'";
proprice = mysqliquery($con, $proprice);
price = mysqlifetcharray($runproprice)){
$productprice = array($ppprice['productprice']);
title = $ppprice['producttitle'];
$productimage = $ppprice['productimage'];
price = $ppprice['productprice'];
$values = arraysum($productprice);
$total +=$values;

<td><input type="checkbox" name="remove[]" class="remove" value="<?php echo $pro_id; ?>"/></td>
<td><img src="admin_area/product_image/<?php echo $product_image; ?>" width="auto" height="45"/></td>
<td><?php echo $product_title; ?></td>

<!-- quantity update input -->
<td><input type="text" style="width:60px;" size="4" name="qty" value="<?php echo $_SESSION['qty']; ?>" /></td>

<!-- quantity update function -->
$qty = $POST['qty'];
qty = "update cart set qty='$qty'";
$runqty = mysqliquery($con, $updateqty);
$total = $total*$qty;
?> <td><?php echo "$" . $single_price; ?></td>
</tr> <?php }} ?>

<!-- cart update button -->

 <tr align="right"><td colspan="5"><input type="submit" name="update_cart" value="Update Cart" class=" btn-checkout"/></td></tr>


<div style="width:400px; float: right;">
<h1>Cart Total</h1>
<table style="border:1px solid grey;" class="table">
<th>Subtotal </th>
<td><?php echo "$" . $total; ?></td>
<tr align="right"><td colspan="2"><button type="button" class="btn-checkout"><a href="checkout.php" style="text-decoration: none; color:black;">Checkout >></a></button></td></tr>