<?php
	include('/var/www/html/uclit/protected/common/login/check.php');
	include('/var/www/html/uclit/protected/common/css_login/css_head2.php');
	include('/var/www/html/uclit/protected/connections/db_pers.php');

		if (isset($_POST['search_input']))
		{
			$column_field = $_POST['search_option'];
			$search_string = strtoupper($_POST['search_input']);
			
			$db = mysql_select_db("uclit_db") or die ("Could not select database uclit_db.");
			$sql = "SELECT * FROM personnel WHERE $column_field='$search_string'";
			$sql_result = mysql_query($sql, $uclit_dbConn) or die ("Unable to exercute query.<p>$sql</p>");
			
			if(($row = mysql_fetch_row($sql_result)) < 1)
				echo "
					  <h2>Search result for $column_field matching '$search_string'</h2>
				      <p>No record matching $search_string in personnel table</p>
				     ";
			else
			{
					$personnel_id = $row[0];
					$last_name = $row[1];
					$first_name = $row[2];
					$middle_name = $row[3];
					$dept_id = $row[4];
					$e_mail = $row[5];
					$phone = $row[6];
					$web_role = $row[7];
					$room = $row[8];
					$duties = $row[9];
					$duties_sec = $row[10];
					$title = $row[12];
					$ID_Num = $row[13];
					$PAF = $row[14];
					$PAF_date = $row[15];
					$working = $row[18];
									
				$display_block = 
				"<table>
				   <tr><td><strong>Personnel_:</strong>&nbsp;<i>$personnel_id</i><td></tr>
				   <tr><td><strong>Last Name:</strong>&nbsp;<a href='http://ul.uc.edu/uclit/protected/personnel/show_addemployee.php?pid=$personnel_id&uaction=edit'><i>$last_name</i></a>&nbsp;&nbsp;<b><font color='red'><<<<< Click to Edit</font></b></td></tr>
				   <tr><td><strong>First Name:</strong>&nbsp;<i>$first_name</i></td></tr>
				   <tr><td><strong>Middle Name:</strong>&nbsp;<i>$middle_name</i></td></tr>
				   <tr><td><strong>Email:</strong>&nbsp;<i>$e_mail</i></td></tr>		
				   <tr><td><strong>Phone:</strong>&nbsp;<i>$phone</i></td></tr>
				   <tr><td><strong>Official Title:</strong>&nbsp;<i>$title</i></td></tr>
				   <tr><td><strong>Working Title:</strong>&nbsp;<i>$working</i></td></tr>
				   <tr><td><strong>Room:</strong>&nbsp;<i>$room</i></td></tr>
				   <tr><td><strong>PAF Received:</strong>&nbsp;<i>$PAF</i></td></tr>
				   <tr><td><strong>PAF Received Date:</strong>&nbsp;<i>$PAF_date</i></td></tr>
			       </table>";

				echo "
						<h2>Search result for $column_field matching '$search_string'</h2>
						$display_block
						<br>
						<a href='http://ul.uc.edu/uclit/protected/personnel/show_allemployee.php'>List All Employees</a>
				     ";

			}
		}
		else  
		{
			header("Location: ./uclit/protected/personnel/show_employeesearch.php");
			exit;				
		}
		
include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); ?> 