<?php



include 'connect.php';



$product=$_GET['product'];

$factory=$_GET['factory'];



$pur=mysqli_query($conn,"select sum(qty) as qty from purchase where product='$product' and factory='$factory'");

$pur1=mysqli_fetch_assoc($pur);



$sal=mysqli_query($conn,"select sum(qty) as qty from invoice where product='$product' and factory='$factory'");

$sal1=mysqli_fetch_assoc($sal);



$prodc=mysqli_query($conn,"select sum(input_qty) as qty from production where input_product='$product' and factory='$factory'");

$prodc1=mysqli_fetch_assoc($prodc);



$prodct=mysqli_query($conn,"select sum(output_qty) as qty from production where output_product='$product' and factory='$factory'");

$prodct1=mysqli_fetch_assoc($prodct);



$bal=$pur1['qty']-$sal1['qty']-$prodc1['qty']+$prodct1['qty'];





echo"<div id='stock'>".number_format($bal,2,'.','')."</div>";



?>