









<?php




include('db_con.php');




$debit = 0;




$credit = 0;




$stock = 0;




 if(isset($_POST['item_no']))




	{




		$item_no = $_POST['item_no'];




	




		$sql = "SELECT sum(qty) FROM purchase_detail WHERE item_no = '".$item_no."'";




            $statement = $connect->prepare($sql);




            $statement->execute(); // no need to add `$sql` here, you can take that out




           




            




            $debit = $statement->fetchColumn();




            $stock = $debit - $credit;














            $output['instock'] = $stock;




		echo json_encode($output);




	}









		
























	




	




?>