<table width="200" border="0" align="center">
  <tr>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/sort_helpcalls.php"><img src="sort3.jpg" alt="Sort" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/show_tech.php"><img src="Check3.jpg" alt="Check" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/show_hreport.php"><img src="Report3.jpg" alt="Report" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/show_calls.php"><img src="Knowledge3.jpg" alt="Knowledge" width="120" height="50" border="0" /></a></td>
  </tr>
</table>

<?php
	include('/var/www/html/uclit/protected/connections/db_help.php');
		
	//Select a database
	$db1 = mysql_select_db('helpcalls', $helpConn) or die("Couldn't select helpcalls database ");
	$query= "SELECT help_id, date_arrived, help_catagory, help_phone, help_desc, help_dept, help_user, help_resolution, help_tech FROM log WHERE (completed is NULL or Completed='0' AND help_catagory = '') ORDER BY help_tech";
		
	//execute query
	$result = mysql_query($query, $helpConn) or die("Couldn't execute query. <p>$query</p>");
	
	
	while ($row = mysql_fetch_array($result))
	{
		$count = count($result);
		$help_id=$row['help_id'];
		$date_arrived = $row['date_arrived'];
		$help_type = $row['help_catagory'];
		$help_desc = $row['help_desc'];
		$help_dept = $row['help_dept'];
		$help_user = $row['help_user'];
		$help_resolution = $row['help_resolution'];
		$help_tech = $row['help_tech'];
		
		$display_block .="<tr>
						   <td>$date_arrived</td>
						   <td>$help_type</td>
						   <td>$help_dept</td>
						   <td>$help_tech</td>
						   <td>$help_desc</td>
						   <td>$help_user</td>
						   <td  align='center'><a href='http://ul.uc.edu/uclit/teaming/helpcalls/edit_sortcalls.php?help_id=$help_id'><img src='../../images/edit.gif' border='0'></a></td>
						 </tr>";
	}		

	if ($count <= 0)
	{
		echo "<h2>No help calls need to be sorted.</h2>
	";
	}
	else
	{

		echo " 
		<h1>Helpcalls to Sort</h1>
		<table border='1' id='output'>
		<tr>
		  <td align='center'><b>Date Arrived</b></td>
		  <td align='center'><b>Catagory</b></td>
		  <td align='center'><b>Department</b></td>
		  <td align='center'><b>Assigned To</b></td>
		  <td align='center'><b>Description</b></td>
		  <td align='center'><b>Posted By</b></td>
		  <td align='center'><b>Edit</b></td>
		  </tr>
		$display_block
		</table>";
	}
?>