I do something similar to that. Here's part of that code. I'm sure you could modify it to suit your needs.
$query = "SELECT deal FROM deals WHERE deal LIKE '%$keyword%'";
$result = mysql_query($query) or die("Query failed: " . mysql_error());
$num = mysql_num_rows($result);
echo "Your search returned <strong>$num</strong> results:<ul>\n";
while (list($deal) = mysql_fetch_row($result)){
$pos = strpos(strtolower($deal), strtolower($keyword));
$start = $pos - 85;
if ($start < 0) $start = 0;
$shortdeal = substr($deal, $start, 175);
$newdeal = eregi_replace ("$keyword", "<strong>\\\\0</strong>", $shortdeal);
if ($start > 0) echo "...";
echo "<li>$newdeal...</li>\n";
}
echo "</ul>";
Something along those lines. Obviously, I've removed a lot of the irrelevant code. I haven't looked it over too thoroughly, but hopefully I haven't removed anything vital.