nandananushil1
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.