<? session_start(); ?>
<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$code=$_REQUEST['code'];


?>
<link rel="stylesheet" href="style.css" type="text/css" />
<body bgcolor=fcfff1>
<font color=green>
<h3>List of Branches</h3></font>

<?
$result=mysqli_query($db,"select * from branch order by brcity")or die(mysqli_error($db));
?>
<table border=0  cellspacing=2 cellpadding=5 class=report>
<th>No.<th>Branch Name <th>Br. Code <th>Address <th>City <th>State <th>Phone <th>Type <th>VECV Pur<th>Local Pur <th>Action
<?
$i=1;
while($row=mysqli_fetch_array($result))
{
 print "\n<form action='$PHP_SELF' method='POST'> <input type=hidden name='code' value='$row[0]'>";
 print "\n<tr bgcolor='c1d7bf' onMouseOver=bgColor='Pink'; onMouseOut=bgColor='c1d7bf'; ><td>".$i++."</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td><td>$row[brstate]</td><td>$row[5]</td>";
print "<td>$row[brtype]</td><td>$row[vecvpur]</td><td>$row[localpur]</td>";
 print "<td><input type=button name='edit' value='Edit' onClick=javascript:edfun('$row[0]','$row[16]')> \n";
?>
<input type=button name='del' value='Delete' onClick=javascript:del1('<? echo $row["0"] ?>','<? echo $row["1"] ?>')></td></form> </tr>
<?
}
?>
</table>
<script>
function edfun(a,b)
{
 document.location='editbr.php?code='+a;
}
function del1(a,b)
{
alert(b);
 x=confirm("Do you want to delete the branch '"+b+"'");
if(x)
{
 document.location='delbranch.php?code='+a;
}

}
</script>
