1234567891011121314151617181920212223242526272829

<?php
//search data
$search = $_GET['search'];
$search = strip_tags($search);
$search = mysql_real_escape_string($search);

//check if search if not empty
if ($search =='') {
	echo "<div class='msg-error'>Opps! You forgot to enter a search word</div>n";
} else {	

		//perform the database search
		$q = mysql_query("SELECT * FROM table WHERE MATCH(pageConent) AGAINST('$search' IN BOOLEAN MODE)");
		$n = mysql_num_rows($q);
		if($n !=0){//there is a match
		    
		    //make search terms an array of terms
			$words = explode(" ",$search);
			while ($r = mysql_fetch_object($q))
			{
				//pass content to the function and print
				echo highlightWords($r->pageConent, $words);
			}

		}
}
?>