<?php
    include 'load.php';
    require_once 'db_connection.php';  
    
       
   
if(isset($_POST['id']) && isset($_POST['val'])){
    $tempid = $_POST['id'];
    $qty = $_POST['val'];
    $cartinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE tempid='$tempid'"));
    $proid = $cartinfo['proid'];

    $stockinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM tbl_stock WHERE prid='$proid'"));
    $productqty = $stockinfo['qty'];

    if($productqty > $qty){

    $sql = "UPDATE mobiletemporarycart SET pro_qty='$qty' WHERE tempid='$tempid'"; 


    if ($conn->query($sql) === TRUE) {}
    }
}
  
        
       
?>