<?
$q=0;
$w=$GLOBALS['db']->query("select quantity_in,quantity_out from ecmstockins where product_id='".$_REQUEST['record']."' and stock_id='".$_REQUEST['stock_id']."'");
//print mysql_error();
while($r=$GLOBALS['db']->fetchByAssoc($w))
{
	//print $r['quantity_in']." ".$r['quantity_out']."<BR>";
	$qty=$r['quantity_in']-$r['quantity_out'];
	$q+=$qty;
}
print $q;
?>