









<?php




include('db_con.php');




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




	{




	




		$query = "




		SELECT * FROM stock WHERE item_no = :item_no 




		";




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




		$statement->execute(




			array(




				':item_no'	=>	$_POST["item_no"]




				




				




			)




		);




		$result = $statement->fetchAll();




		foreach($result as $row)




		{




			




			




			$output['item_cost'] = $row['item_cost'];




			$output['retail_price'] = $row['retail_price'];




			




			




			




			




			




		}









		$query = "




		SELECT sum(qty) as total_stock FROM purchase_detail WHERE item_no = :item_no 




		";




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




		$statement->execute(




			array(




				':item_no'	=>	$_POST["item_no"]




				




				




			)




		);




		$result = $statement->fetchAll();




		foreach($result as $row)




		{




			




			




			




			$output['total_stock'] = $row['total_stock'];




			




			




			




			




			




		}
























		echo json_encode($output);




	}









		
























	




	




?>