<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 ");
	
	$bdate = $_POST['bdate'];
	$edate = $_POST['edate'];
	$help_type = $_POST['catagory'];
	$term = $_POST['term'];
	
	if($bdate > $edate)
	{
		echo "<script language='javascript'> history.back(-1);</script>";
	}

	
	$sql = "SELECT COUNT(*) AS 'icount' FROM log WHERE (MATCH (Help_Desc, Help_Resolution) AGAINST ('$term*' in boolean mode)) AND (Help_Catagory='$help_type') AND(Date_Completed BETWEEN '$bdate' AND '$edate')";
	
	
		$count_result = mysql_query($sql, $helpConn) or die ("Unable to execute query<p>$sql</p>");
		
		while($row = mysql_fetch_array($count_result))
		{
			$icount = $row['icount'];
			echo"Count = $icount&nbsp;";
		}
	
	
	
	//sql statement to select help catagories
//	$query = "SELECT * FROM log WHERE (Help_Catagory='$help_type') AND (Date_Completed BETWEEN '$bdate' AND '$edate') AND ((Help_Desc LIKE '%$term%') OR (Help_Resolution LIKE '%$term%'))";
//	$query = "SELECT * FROM log WHERE ((Help_Catagory='$help_type') AND (Date_Completed BETWEEN '$bdate' AND '$edate') AND (MATCH (Help_Desc, Help_Resolution) AGAINST ('%$term%' in boolean mode)))";
	$query = "SELECT * FROM log WHERE (MATCH (Help_Desc, Help_Resolution) AGAINST ('$term*' in boolean mode)) AND (Help_Catagory='$help_type') AND(Date_Completed BETWEEN '$bdate' AND '$edate')";
	
	
	
	//execute query statement for help catagories
	
	echo"
	<table border='1'>
	  <tr>
		<td align='center'>Date</td>
		<td align='center'>Department</td>
		<td align='center'>Description</td>
		<td align='center'>Resolution</td>
	  </tr>
	  <tr>";

	//execute query
	$result = mysql_query($query, $helpConn) or die("Couldn't execute query. <p>$query</p>");
			
	while ($row = mysql_fetch_array($result)) 
	{
		$help_id=$row['Help_ID'];
		$date_completed= $row['Date_Completed'];
		$help_desc = $row['Help_Desc'];
		$help_dept = $row['Help_Dept'];
		$help_resolution = $row['Help_Resolution'];
			
		echo "<tr>
				<td>$date_completed</td>
				<td>$help_dept</td>
				<td>$help_desc</td>
				<td>$help_resolution</td>
				</tr>";
	}		
	echo"
	</table>
";

	
?>	