I have searched the forums and found the results confusing. I am not that much of a newbie but feel this is rather a noobish question....
If i have a search page how can i get it to seperate the keywords into individual words and highlight them individually.
i.e: if i have in the url ...keyword=hello+world
How can I have it replace individually hello and world ?
I can make it replace the whole thigneasilly enough but its sperating it into sections which has thrown me.
Would I be right in thinking id use explode and foreach?
Any leads would be awesome.
OK to further my progress I am using this tos earch my DB for the keywords. However it only returns the results of the last keyword. How can I have it include everything? This si ym code:
$keyword = explode(" ", $_GET['keyword']);
foreach ($keyword AS $v) {
$sql = mysql_query("SELECT * FROM privatemessages WHERE from_user='".$_SESSION['MCuserID']."' AND message LIKE '%".$v."%'");
}
Ok, I now have that working in another way. However I have ran into this problem now....
When I attempt to highlight my string it only highlights the last word if there are more than one. say the highlight=hello+world only world is highlighted.
$highlight = explode(" ", $_GET['highlight']);
foreach ($highlight AS $v) {
$message = str_replace($v, "<font color=red>$v</font>", $row['message']);
}