<?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="30%"></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 align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<?php
								echo 'Welcome: ' . $_SESSION['username'];
								?>
							<a href="staff_logout.php"><img src="images/logout3.gif" align="right"></a>
							</td>
</tr>
<tr><td>
<h2 align="center">UPDATE STAFF RECORD</h2>

<?php
       $staff_id = $_REQUEST['staff_id'];
		//echo $staff_id;

       $sql = "SELECT * FROM tbl_dir_staff WHERE staff_id = '$staff_id'";
																		
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				// $row = mysql_fetch_array($result, MYSQL_ASSOC);			
				$row=mysql_fetch_array($result);
			    $staff_id=$row['staff_id'];
			
		?>
				<?php // echo $staff_id;?>
				
				<form  method="post" >
<table class="imagetable" align="center">
<tr align="center"><td>Staff Name</td><td> : </td><td><input type="text" size="100" name="staff_name" value="<?php echo $row['staff_name']?>"></td></tr>
<tr><td>Section</td><td> : </td><td><select name="staff_section" >
                                    <option ><?php echo  $row['staff_section']; ?></option>
                                <?php $section_query=mysql_query("select * from tbl_ref_section order by section_name")or die(mysql_error());
                                       while($row_section=mysql_fetch_array($section_query)){?>
                                    <option> <?php echo $row_section['section_name']; ?>
                                <?php } ?>
                                </option>
                              </select></td></tr>
<tr><td>Designation</td><td> : </td><td><select name="staff_designation" >
                                   <option ><?php echo  $row['staff_designation']; ?></option>
                                 <?php $design_query=mysql_query("select * from tbl_ref_designation order by designation_name")or die(mysql_error());
                                       while($row_design=mysql_fetch_array($design_query)){?>
                                   <option> <?php echo $row_design['designation_name']; ?>
                                <?php } ?>
                                </option>
                            </select></td></tr>
<tr><td>Extension</td><td> : </td><td><input type="text" size="11" name="staff_ext" value="<?php echo $row['staff_ext']?>"></td></tr>
<tr><td>H/Phone</td><td> : </td><td><input type="text" size="20" name="staff_hp" value="<?php echo $row['staff_hp']?>"></td></tr>
<tr><td>Email</td><td> : </td><td><input type="text" size="20" name="staff_emel" value="<?php echo $row['staff_emel']?>">@picc.com</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="STAFF LIST" onClick="window.location.href='staff_admin.php'">
</td></tr>
</table>
</td></tr>
<input type="hidden" name="staff_id" value="<?php echo $staff_id;?>">
</form>
<?php
// escape variables for security
if (isset($_POST['save'])){

       $staff_name = $_POST['staff_name'];
    $staff_section =$_POST['staff_section'];
 //$staff_section_id =$_POST['staff_section_id'];
$staff_designation = $_POST['staff_designation'];
        $staff_ext = $_POST['staff_ext'];
         $staff_hp =$_POST['staff_hp'];
       $staff_emel = $_POST['staff_emel'];
     //$staff_assign = $_POST['staff_assign'];

// insert record into database
$sql1="update tbl_dir_staff set staff_name='$staff_name',staff_section='$staff_section', staff_designation='$staff_designation',
      staff_ext='$staff_ext',staff_hp='$staff_hp', staff_emel='$staff_emel'  where staff_id='$staff_id'";
	  //,staff_assign='$staff_assign'

$result1=mysql_query($sql1);
if($result1)
echo "<script language='javascript'>window.location='staff_admin.php'</script>";

else
   
   echo 'Unsuccessfull update';
   }
?>
<!-- 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>


