highlighting search term results

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
  I've seen previous threads but I still need help in highlighting
search terms like google does on their search result page.

I know I need, ob_start();
Then I process to highlight the search term hits, then I flush the
buffer to render the page.

I'm comfortable with PHP coding but what I need is simple step by step
help, with a simple search form example.
The explanations I see are either way to lofty or too small a piece of
the "puzzle".

Lee G.

Re: highlighting search term results

leegold2 wrote:
Quoted text here. Click to load it

Actually, when preforming local (database) searches, you don't.  It all
comes down to highlight the appropriate pieces of text.

Quoted text here. Click to load it

Then, explain in more detail what the requirements are. If you want to do it
like Google, you don't have to worry about tags, because Google indexes text
fragments only.

On the other hand, when there are html tags in text matches, the following
snippet I posted a while ago might be of interest to you:


I have also an example which applies a search on the file system (warning:
str_ireplace() is supported in PHP version >= 5):



Re: highlighting search term results

Quoted text here. Click to load it

http://www.alistapart.com/articles/searchhighlight /

Site Timeline