<?php  session_start();

/*
	include_once("config.inc.php");
	include_once("DBConnector1.php");
	$letters = $_GET['letters'];
	
	$sql="SELECT * FROM mast_family where name like '".$letters."%'";
		$result =$db->RunQuery($sql);
			
			
			while($row = mysqli_fetch_array($result))
			{
			
			echo $row["name"];
			
			}
			
		*/	
		
		



	include_once("connectioni.php");


//$sql_item = mysqli_query($GLOBALS['dbinv'],"select * from s_mas where BRAND_NAME='CHENG SHING' and STK_NO='06010' order by STK_NO") or die(mysqli_error($GLOBALS['dbinv']));				
$sql_item = mysqli_query($GLOBALS['dbinv'],"select * from s_mas where BRAND_NAME='CHENG SHING' order by STK_NO") or die(mysqli_error($GLOBALS['dbinv']));				
while($row_item = mysqli_fetch_array($sql_item)){	

	$sql1 = mysqli_query($GLOBALS['dbinv'],"select sum(QTYINHAND) as tot from s_submas where STK_NO='".$row_item["STK_NO"]."' ") or die(mysqli_error($GLOBALS['dbinv']));
	$row1 = mysqli_fetch_array($sql1);
	
	
	//$sql1 = mysqli_query($GLOBALS['dbinv'],"update s_submas set QTYINHAND=".$M_BAL." where STO_CODE='".$row_sto["CODE"]."' and STK_NO='".$row_item["STK_NO"]."'") or die(mysqli_error($GLOBALS['dbinv']));
	$sql1 = mysqli_query($GLOBALS['dbinv'],"update s_mas set QTYINHAND=".$row1["tot"]." where STK_NO='".$row_item["STK_NO"]."' ") or die(mysqli_error($GLOBALS['dbinv']));
//	echo "update s_mas set QTYINHAND=".$M_BAL." where STK_NO='".$row_item["STK_NO"]."'</br>";


}
	echo "ok";
?>
