<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
if($submit)
{
 if(strlen($lname)<=0)
  {
     print "<script> alert('In sufficient entry'); history.back(1);  </script>";
     return;
  }

 $code=substr($lname,0,3).substr(time(),7,3); 
 $code=str_replace(' ','-',$code);

 $sql="insert into loc_master values('$code','$lname','$rem','$brcode')";
 mysqli_query($db,$sql) or die(mysqli_error());
 print "<font color='Green'> Data has been saved</font>";
}

?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>

<CENTER>
<BR>
<FORM ACTION='<?print $PHP_SELF?>' METHOD='POST'>
<table cellspacing=1 cellpadding=1 bgcolor=green>
<tr><td align=center>
<table>
<tr><td colspan=2 align=center>LOCATION MASTER</TD></TR>
<tr><td><font color=red>Name </td><td><input type=text name='lname' size=40></td></tr>
<tr><td>Remark </td><td><input type=text name='rem' size=40></td></tr>
<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT name='submit' VALUE='  SAVE  '></TD></TR>

</table>
</td></tr>
</table>
</form>

<br>
<?
$result=mysqli_query($db,"select * from loc_master where brcode='$brcode' order by lname")or die(mysqli_error());
print "<table cellspacing=1 cellpadding=1 border=1>";
print "<th> No.<th>Name <th>Remark <th>Edit";

$i=1;
while($row=mysqli_fetch_row($result))
{
 print "<tr><td>".$i++."</td><td>$row[1]</td><td>$row[2]</td>";
 print "<td><a href='editloc.php?code=$row[0]'> <img src='../img/signit.gif' border=0></a> </td> </tr>";
}
?>
</table>
