<?php session_start();?>
<?php require_once('open_connection.php');?>
<!--link href='blue/style.css' rel='stylesheet' type='text/css' /-->
<link href='css/imagetable.css' rel='stylesheet' type='text/css' />
<!DOCTYPE html>
<html>
<head>
      <title>PICCSB e-Directory System</title>

</head>
<body bgcolor="#333333"> 

<table width="100%" border="0" align="center">
<tr>
<td width="15%" bgcolor="#333333">&nbsp;</td>
<td width="70%" align="center" bgcolor="#FFFFFF" > 

<table width="100%" border="0" align="center">

<!-- row for header picc 1 -->
<tr>  
     <th width="100%" colspan="4"><img src="images/header-cox.jpg" width="100%" height="100%"></th>
</tr>

<!-- row for header picc 2 -->
<tr>
     <th width="100%" colspan="4"><img src="images/eoffice-cox.jpg" width="100%" height="15%"></th>
</tr>

<!-- calling frame -->	
<tr>
    <td colspan="1" width="10%" align="center"><?php include("header.php");?></td>
	
</tr>
<tr>

<td colspan="3" width="90%" align="center" >
<tr><td>&nbsp;</td></tr>
<tr><td align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<?php
							$user_id=$_SESSION['user_id'];
							echo 'Welcome: ' . $_SESSION['user_name'];
?>
							<a href="admin_logout.php"><img src="images/logout3.gif" align="right"/></a>							
							</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr><td>
<h2 align="center">UPDATE DIVISION RECORD</h2>
<?php
       //$user_id = $_REQUEST['user_name'];

//echo $user_name;
$division_id=$_GET['division_id'];
       $sql = "SELECT * FROM tbl_ref_division WHERE division_id = '$division_id'" ;
																		
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				// $row = mysql_fetch_array($result, MYSQL_ASSOC);
				
				$row=mysql_fetch_array($result);
			    $division_id=$row['division_id'];
			
		?>
				<!--?php echo $category_name;?-->
				
				<form  method="post" >
<table class="imagetable" align="center">
<tr><td>Division ID</td><td> : </td><td><?php echo $row['division_id']?><!--input type="text" size="12" name="division_id" value="<!?php echo $row['division_id']?>"--></td></tr>   
<tr><td>Division Name</td><td> : </td><td><input type="text" size="12" name="Name" value="<?php echo $row['Name']?>"><!--select name="Name" class="input-xlarge">
                                   <option selected="selected"> <!?php
                                     echo $row['Name'];
                                 ?></option>
                                    
                            <!?php
                                $division_query=mysql_query("select * from tbl_ref_division order by division_id")or die(mysql_error());
                                while($row=mysql_fetch_array($division_query)){
                            ?>
                            <option>
                                 <!?php
                                     echo $row['Name'];
                                 ?>
                            </option>
                            <!?php
                                }
                            ?-->
                            <!--/select--></td></tr>    
<tr><td colspan="3" align="center">
<input type="submit" class="myButton" value="UPDATE" name="save" id="save" >
  <input type="button" class="myButton" value="DIVISION'S LIST" onClick="window.location.href='administrator_division_view.php'">
</td></tr>
</table>
</td></tr>
<input type="hidden" name="division_id" value="<?php echo $row['division_id']?>"></form>

<?php
// escape variables for security
if (isset($_POST['save'])){
		$division_id = $_POST['division_id'];    	
		$Name =$_POST['Name'];
		//$section_id = $_POST['section_id'];
       
       

// insert record into database
$sql="update tbl_ref_division set division_id='$division_id',Name='$Name' where division_id='$division_id'";

$result=mysql_query($sql);
if($result)
echo "<script language='javascript'>window.location='administrator_division_view.php'</script>";

else
   
   echo 'Unsuccessfull update';
   }
?>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<!-- row for footer -->	
<tr>
	<th align="center" colspan="4">
	<?php include('footer.php');?>
		
	</th>
</tr>

<!--- end for ruang kerja 80% -->
</table>

</td>

<td width="20%" bgcolor="#333333">&nbsp;</td>

</tr>

<!--- end for ruang kerja 100% -->
</table>

</body>
</html>