0){ $new_qty = $asc_check['qty'] + $qty; $new_price = $new_qty * $prodprice; $update = "update shop_cart set qty='$new_qty', totprice='$new_price' where productid = '$id' and session_id='".$browsessionid."'"; mysql_query($update); }else{ $totprice=$qty * $prodprice; $res=mysql_query("insert into shop_cart(`user_id`,`session_id`,`productid`, `qty`, `price`,`totprice`) values('".$_SESSION['id']."','$browsessionid','$id','1','".$_REQUEST['prodprice']."','".$totprice."')"); } }else{ $qty=1; // $Delete_Question = "DELETE FROM shop_cart WHERE productid='$id' and session_id='".$browsessionid."'"; // //$Result_Question = mysql_query($Delete_Question); // $totprice=$qty * $prodprice; // $res=mysql_query("insert into shop_cart(`user_id`,`session_id`,`productid`, `qty`, `price`,`totprice`) values('".$_SESSION['id']."','$browsessionid','$id','1','".$_REQUEST['prodprice']."','".$totprice."')"); $check_rows = "select qty from shop_cart where productid='$id' and session_id='".$browsessionid."'"; $mycheck = mysql_query($check_rows); $check_count = mysql_num_rows($mycheck); $asc_check = mysql_fetch_array($mycheck); if($check_count > 0){ $new_qty = $asc_check['qty'] - $qty; $new_price = $new_qty * $prodprice; if($new_qty == 0){ $delete = "delete from shop_cart where productid = '$id' and session_id='".$browsessionid."'"; mysql_query($delete); }else{ $update = "update shop_cart set qty='$new_qty', totprice='$new_price' where productid = '$id' and session_id='".$browsessionid."'"; mysql_query($update); } } } } $sql="select sum(qty) as qty from shop_cart where session_id='".$browsessionid."' "; $res=mysql_query($sql); $residue = mysql_fetch_array($res); $rows=mysql_num_rows($res); $objqrynewsubee = "SELECT SUM(totprice) AS amtTotal FROM shop_cart where session_id='$browsessionid'"; $objResultnewsubee = mysql_query($objqrynewsubee); $Fetchnewww = mysql_fetch_array($objResultnewsubee); $subtotal=$Fetchnewww['amtTotal']; ?>