-
I am pulling profiles which mention the word “fitness” from a database like so:
$result = mysql_query("SELECT profile FROM ".$table." WHERE profile LIKE ('fitness')"); -
I am doing a basic retrieval of the
$profilevariable and echo it.while($slice = mysql_fetch_assoc($result)) { $profile = $slice['profile']; echo $profile; }
What I’d like is a way to search the text inside $profile for the word “fitness” and highlight the found word using maybe CSS.
Any ideas how?
UPDATE:
Ty very much, and I have one more problem.
In the sql query I will have:
$result = mysql_query("SELECT profile FROM ".$table." WHERE $profile_rule");
$profile_rule = 'profile LIKE ('fitness') AND profile LIKE ('pets')';
Is there a way to s**trip the $profile_rule** and get just the words fitness and pets? Maybe strip everything which isn’t encased by ” ?
Ty
EDIT: Per your update, take a look at the
IN()operator:EDIT 2: I think I misunderstood your question, though I still recommend edit 1. If you just want to grab the words
fitnessandpetsfrom that$profile_rulestring, use some simple regex: