SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    monitormensch oerdec's Avatar
    Join Date
    Sep 2004
    Location
    Hamburg
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question searching database >> highlighting result

    Hello,

    at this moment Im working on a search script. I want the searched strings to be highlighted in the output.

    for example:

    somebody enters the word monday in the searchfield. My script makes a database query and delivers the hole text: Meatless Monday prevents causes of heart disease, ...

    I want the word monday e.g. with a yellow background or something.

    Im using while and mysql_fetch_object in my script.

    Any ideas or sources?

    thanks,

    oerdec

  2. #2
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try str_replaceing the $word with like <span style="background-color: yellow">$word</span>

  3. #3
    monitormensch oerdec's Avatar
    Join Date
    Sep 2004
    Location
    Hamburg
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, I forgot about that. Unfortunately str_ireplace (case-insensitive) is just PHP 5. So Im now using eregi_replace too.

    oerdec


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •