简体   繁体   中英

shopping cart, matter with quantity

this is a shoping cart is work kind of fine but the matter is with quantity, when the quantity is 1 i like got the single_price automatically any sugestion:

$global = 0;

if(isset($_POST['update_cart'])){
    if(isset($_POST['qty'.$i])){
        $qty = $_POST['qty'.$i];
    }else{
        $qty+=1;    
    }

    $update_qty = "update cart set qty='$qty'";

    $run_qty = mysqli_query($con, $update_qty); 

    $_SESSION['qty']=$qty;



    $global = $global+ ($single_price*$qty); 


    $total =$total + ($values * $qty);


}

I see a problem with the concat replace this :

$update_qty = "update cart set qty='$qty'";

With this :

$update_qty = "update cart set qty='".$qty."';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM