Link to home
Start Free TrialLog in
Avatar of nandananushil1
nandananushil1Flag for India

asked on

my sql text search

i am using mysql and php and i am doing search in a field which is of type text. i would like a part of sentence to be displayed with the search string highlighted.  
example:

i search for ->    bob

text field has --> this is test. this is test. my name is bob. this is test. this is test.

result --> my name is bob, with bob highlighted
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Make a select that return you a record if the text contains search string or null if it doesn't contain it.

Once you have the record you'll need to strip it, use split to convert the string into an array of phrases separated by ".". Now loop through that array seeking in every element if the search string is present, when you find an element of the array with the search string present exit the loop and return to your page the string contained on that array's element with <strong></strong> inserted before and after the search string.
ASKER CERTIFIED SOLUTION
Avatar of JermTheWorm
JermTheWorm
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial