<!--includes for all the database connections-->

<!--loads the php code to connect to databases and queries -->

<!--begin html-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/final_php.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!--template parameters-->
<!--use this editable area to add an additional style sheet-->

<!-- InstanceBeginEditable name="doctitle" -->
<title>Intranet</title>
<!-- InstanceEndEditable -->
<!-- use the editable area below to add any additional head items-->
<!--code to load css for page and menus-->
<?php require_once('../../int05c/incs/loadcss.inc'); ?>
<?php require_once('../../int05c/incs/loadscripts.inc'); ?>
<!--menu hack-->
<!--[if gte IE 5]>
<style>#p7TMnav div a {width: 100%;}</style>
<![endif]-->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body onload="P7_swapClass(0,'none','open','closed','li')"> 
   <div class="skipLinks">
     skip to: <a href="#content">page content</a> | <a href="/pageNav">links on this page</a> | <a     href="#globalNav">site navigation</a> | <a href="#siteInfo">footer (site information)</a>
   </div>
   <div id="header">
    <?php require_once('../../int05c/incs/header.htm'); ?> 
   </div>
   <div id="utility">
    <?php require_once('../../int05c/incs/ut.htm'); ?>
   </div>
   <div id="content"> 
	   <!--left menus-->
	   <div id="pageNav">
	   <?php require_once('../../int05c/incs/nav3.htm'); ?>
	   </div>  
       <!--main content div--> 
       <div class="story"> <!-- InstanceBeginEditable name="content" --> 


<?php
	$db_libstaff = "uclit_db";
	$table_Department = "departments";
	//Create connection
	$connection = @mysql_connect("libitdb.lang.uc.edu", "phpadmin", "25or624")
		           or die("Couldn't connect to MySQL Server.");

	//Select a database to work with
	$db = @mysql_select_db($db_libstaff, $connection)
		   or die("Couldn't select database: db_libstaff");

	$staff_lname = $_POST['lnametext'];
       		
	//SQL Select statement
	$query= "SELECT personnel.personnel_id, personnel.last_name, personnel.first_name, personnel.middle_name, personnel.dept_id, personnel.e_mail, personnel.phone, personnel.web_role, personnel.room, personnel.duties, personnel.duties_sec, personnel.removed, personnel.title, personnel.working_title, personnel.ID_Num, departments.dept_id, departments.dept_name, departments.building, departments.dept_head_id FROM departments INNER JOIN personnel ON (departments.dept_id = personnel.dept_id) WHERE personnel.last_name=\"$staff_lname\" and personnel.removed !=1";

	$result = @mysql_query($query,$connection)
		       or die("Couldn't execute query.<p>$query</p>");

		while ($row = mysql_fetch_array($result)) {
			$idnum=$row['personnel_id'];
			$lname = $row['last_name'];
			$fname = $row['first_name'];
			$deptname = $row['dept_name'];
			$bldg = $row['building'];
			$rmnum = $row['room'];
			$mloc = $row['mail_location'];
			$phonenum = $row['phone'];
			$email = $row['e_mail'];
			$primary =$row['duties'];
			$secondary =$row['duties_sec'];
			$taskforce =$row['web_role'];
			$working =$row['working_title'];
			
		$display_block .="<tr>
						<td align='center'><a href='edit_staff.php?idnum=$idnum'><img src='edit2.gif' border='0'></a></td>
		                  <td>$lname</td>
			            <td>$fname</td>
			            <td>$deptname</td>
			            <td>$bldg</td>
						<td>$rmnum</td>
						<td>$phonenum</td>
						<td><a href=mailto:$email>$email</a></td>
						
						</tr>";
	}

echo"

<H1 align=\"center\">Staff by Last Name</H1>
<center>

<table width=95% border=1>
<tr>
          <td align=center><b>Edit</b></td>
          <td align=center><b>Last Name</b></td>
		  <td align=center><b>First Name</b></td>
		  <td align=center><b>Department</b></td>
		  <td align=center><b>Building</b></td>
		  <td align=center><b>Room #</b></td>
		  <td align=center><b>Phone Number</b></td>
		  <td align=center><b>Email</b></td>
</tr>
$display_block
</table> 
"
?>
<P><a href="http://ul.uc.edu/resources/phonebook/show_staff_name.html">Return to Enter a Last Name</a></p>
       <p>
       <p>&nbsp;</p>
       <!-- InstanceEndEditable -->       </div>
   </div>
   
 <div id="siteInfo"> 
 <?php require_once('../../int05c/incs/footer.htm'); ?>    
 </div>

</body>
<!-- InstanceEnd --></html>
<!-- clear all queries and free the databases-->
