#Filename: auto_suggest.php
	#Description: This file takes the text entered in the search input box and returns up to 5 results from names table
	#Input: $_GET['content'] - this is the string entered in the input box
	#Output: up to 5 results are echoed in a table format with onclick handlers that will put the clicked option into the
	#	input box and hide the list of options.  There are also mouseover handlers that will change the color of the
	#	option when you mouse over it, and the characters typed in (that were searched for) are made bold within the 
	#	options display.
	include('db.php'); // connect to the database
	$str = strtolower($_GET['content']);
	$str = trim($str);
	if(strlen($str)>1) { //only query the database if the string has at least 2 characters
		$str = addslashes($str);
		$query = "select name,id from names where name like '$str%' limit 0,5";
		$selectResultSet = mysql_query($query);
		if(mysql_num_rows($selectResultSet)>0) {
			echo "<script language=\"javascript\">box('1');</script>";
			echo "<table border =\"0\" width=\"100%\">\n";
			while($row = mysql_fetch_array($selectResultSet)) {
				$name_option = str_ireplace($str,"<b>".$str."</b>",($row['name']));
				$name_to_use = trim($row['name']);
				echo "<tr id=\"word".$row['id']."\" style='border-collapse:collapse' bgColor=\"white\" ".
					"onmouseover=\"highlight(1,'".$row['id']."');\" onmouseout=\"highlight(0,'".$row['id']."');\" ".
					"onClick=\"display('".$name_to_use."');\" >\n<td>".$name_option."</td>\n</tr>\n";
			} // end of loop through database results
			echo "</table>";
		} // end of check for any results
	} else echo "<script language=\"javascript\">box('0');</script>";