<?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>
<h2 align="center">UPDATE CATEGORY RECORD</h2>
<?php
       //$user_id = $_REQUEST['user_name'];

//echo $user_name;
$category_id=$_GET['category_id'];
       $sql = "SELECT * FROM tbl_ref_ecategory WHERE category_id = '$category_id'" ;
																		
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				// $row = mysql_fetch_array($result, MYSQL_ASSOC);
				
				$row=mysql_fetch_array($result);
			    $category_id=$row['category_id'];
			
		?>
				<!--?php echo $category_name;?-->
				
				<form  method="post" >
<table class="imagetable" align="center">
<tr><td>Category ID</td><td> : </td><td><?php echo $row['category_id']?><!--input type="text" size="12" name="category_id" value="<!?php echo $row['category_id']?>"--></td></tr>    
<tr><td>Category Name</td><td> : </td><td><input type="text" size="12" name="category_name" value="<?php echo $row['category_name']?>"></td></tr>    
							<!--select name="category_name" >
                                <option ><!?php echo  $row['category_name']; ?></option>
                                <!?php $cat_query=mysql_query("select * from tbl_ref_ecategory order by category_id")or die(mysql_error());
                                       while($row=mysql_fetch_array($cat_query)) {?>
                                <option> <!?php echo $row['category_name']; ?>
                                <!?php } ?>
                                </option>
                              </select></td></tr>
<!--<tr><td>Assign Name</td><td> : </td><td><input type="text" size="20" name="staff_assign" value="<!?php echo $row['staff_assign']?>"></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="CATEGORY LIST" onClick="window.location.href='administrator_category_view.php'">
</td></tr>
</table>
</td></tr>
<input type="hidden" name="category_id" value="<?php echo $row['category_id']?>"></form>
<?php
// escape variables for security
if (isset($_POST['save'])){
		$category_id = $_POST['category_id'];    	
		$category_name =$_POST['category_name'];
		//$section_id = $_POST['section_id'];
       
       

// insert record into database
$sql="update tbl_ref_ecategory set category_id='$category_id',category_name='$category_name' where category_id='$category_id'";

$result=mysql_query($sql);
if($result)
echo "<script language='javascript'>window.location='administrator_category_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>