<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
if($save)
{
 $r=mysqli_query($db,"select * from deptmast where deptname='$deptname' and brcode='$brcode'");
  if(mysqli_num_rows($r)>0)
  {
    print "<script> alert('Duplicate Division'); </script>";
    return;
  }
 $sql="insert into deptmast (brcode,deptname) values('$brcode','$deptname')";
 mysqli_query($db,$sql) or die(mysqli_error());
 print "<font color=green> Data has been saved</font>";
}
if($del)
{
 mysqli_query($db,"delete from deptmast where code='$code' and brcode='$brcode'");
}
?>

<head>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:e3ecd2}
th{background-color:c1d799}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style>
<center>
<form action='<?print $PHP_SELF ?>'>
<table>
<th colspan=2>DEPARTMENT MASTER</th>
<tr><td>Division Name</td><td><input type=text name='deptname' size=40 onKeyDown=chkey(this)></td></tr>
<tr><td colspan=2 align=center bgcolor=c1d799> <input type=submit name='save' value='Save'></td></tr>
</table>
</form>
<HR>
EXISTING DIVISIONS
<HR>
<table width=50%>
<th width=12>No <th>Division <TH width=50>Action
<?
$result=mysqli_query($db,"select * from deptmast where brcode='$brcode' order by deptname");
$i=1;
while($row=mysqli_fetch_array($result))
{
 print "\n<form action='$PHP_SELF'><input type=hidden name=code value='$row[code]'>";
 print "\n<tr><td>".$i++."</td><td>$row[deptname]</td><td><input type=submit value='Del' name='del'></td></tr></form>";
}
?>
</table>

<br>&nbsp;
