Yes I did. it was much simpler than i had thought as MySQL has a built in tool to already do this!
here is the code in case someone is looking for it in the future
$searchstring= $_GET['searchstring'];
$query = "SELECT * FROM job_tracking.board INNER JOIN job_tracking.users ON board.user = users.USER_ID WHERE MATCH (subject, body, emp_ref, user, NAME) AGAINST ('$searchstring' IN BOOLEAN MODE)";
$row = mysql_query($query, $connection);
This does a search for whatever string is entered into the $searchstring variable. I get this from a form. It checks for the individual keywords in the search string against the fields subject, body, emp_ref, user, NAME and rreturns the records with the them. I chose to use the BOOLEAN mode as this will also do some more advanced resume searching and i want the users to allow for more complex searching.
I Then added a function to my header to highlight the keywords in the output text.
$body is the text to be searched and outputed and $keys are the search words taken from the $searchstring variable used in the SQL Statement.
First it checks for anything in the $keys field, just in case you're loading the particular field without search criteria (whcih mine does on occasion) and then searches the text and replaces it with a new formatted output. It then passes the formatted output back to my main script.
function highlight($body, $keys)
{
$search_results = $body;
if($keys)
{
$words= str_replace(" ","|",trim($keys));
$text = eregi_replace($words,"<font color='red'><strong>\\0</font></strong>",$search_results);
return $text;
}
else
{
return $body;
}
}
When all is said and done, I call upon it to print very simply
print(highlight($text, $searchstring));
and the output has the text i want highlighted.