Jump to content

Recommended Posts

Hi all

I have a database which holds lots of text, I have made a simple search system. What I want to do is to highlight the word they searched, they way I thought of doing it was

[code]<? print strtr($row['text'], "'".$_GET['searchterm']."'", "<strong>'".$_GET['searchterm']."'</strong>"); ?>[/code]

But then found that I cannot use html within that tag and also it is case sensative, so if someone searches for Internet and the word is stored as internet, then it wouldnt find it. Can anyone help?

Thanks in advance as always

Dave
Link to comment
https://forums.phpfreaks.com/topic/13846-highligting-words/
Share on other sites

is that strtr a typo and you meant str[b]s[/b]tr? strtr and strstr are two different functions. i suspect that you meant to use strstr(). if you are using the first, strtr() takes 2 arguments, not 3, as you have. I suspect that's why you "cant" use html. and as far as case sensitivety, use str[b]i[/b]str() instead of strstr, as it is case in-sensitive.
Link to comment
https://forums.phpfreaks.com/topic/13846-highligting-words/#findComment-53889
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.