<?php



include 'connect.php';



$product=$_GET['product'];

$factory=$_GET['factory'];



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

$pur1=mysql_fetch_array($pur);



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

$sal1=mysql_fetch_array($sal);



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

$prodc1=mysql_fetch_array($prodc);



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

$prodct1=mysql_fetch_array($prodct);



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





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



?>