<?
session_start();
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
 
$re=mysqli_query($db,"select * from sparestock where brcode='$brcode' order by itemcode")or die('err:'.mysqli_error($db));
while($row1=mysqli_fetch_array($re))
{
    $mitemcode = $row1[itemcode];
    $re1=mysqli_query($db,"select gname from partmaster where partcode = '$mitemcode'")or die('err:'.mysqli_error($db));
    $row2=mysqli_fetch_array($re1);
    $mgname = $row2[0];
    $re1=mysqli_query($db,"update sparestock set item_grp = '$mgname' where itemcode = '$mitemcode' and brcode='$brcode'")or die('err:'.mysqli_error($db));
}
?>