<?php 
include("db_config.php"); 
if($_SERVER['REQUEST_METHOD']=='POST'){
	$product_id = $_POST['product_did'];
	$sql="select * from product_detail  where id='$product_id'";
    $result = mysqli_query($conn, $sql);
	$row= mysqli_fetch_assoc($result);
	$sql_qry=mysqli_query($conn,"select count(quantity) as prd from addto_cart where prod_details_id='".$product_id."' and invoice_id='0'");
    $res_data= mysqli_fetch_assoc($sql_qry);
    $tprd=(int)$res_data['prd'];
    $left=$row['total_no_prod_quantity'] - $tprd;            
    $response['product_count']=$left;
	echo json_encode($response);
	mysqli_close($conn);
}