0

Hi! I make nws CMS for self. I added search function too. But I have problem. I save data with html at DB

Sample: <font color=red>Some text</font> When I search for string "some" I get this row. But when I search for string "font" , I also get this row to show. It is not good. Because font is html tag. Is there another way dont search in DB into "<>" tags. Sorry for my poor English. Thank you!

4
Contributors
7
Replies
8
Views
9 Years
Discussion Span
Last Post by pritaeas
0

If your storing the text in the db like that then your going to have to add:

NOT LIKE '%font%' and NOT LIKE '%head%' and NOT LIKE '%br%'

However this might yield undesired results. I would look for something else to search by or explain what/why your searching this way and maybe I can think of a better solution.

0

Thx for reply. I whrite string "font" for sample. To list all HTMl tags is impossible. Maybe another way not search stings at Database which opened and closed with "<" and ">" tags. Sample row at database:

<b><font color="#0000FF">Lorem ipsum</font> <div> Lorem ipsumLorem ipsum</div><a href="site.com">Lorem ipsum</a>

I want that users may not search strings(tags) which enclosed with < and > tags.

maybe RegExp method or another simple method.


Thank you for gold time which you spend to answer my thread.:icon_idea:

0

One option is to add an additional column that has only the searchable text in it. This could be generated by the script that builds the table to begin with.

0

It may be possible to do this by using REGEX in the WHERE clause. It will be a complicated one, but maybe someone here has more experience with it.

0

It may be possible to do this by using REGEX in the WHERE clause. It will be a complicated one, but maybe someone here has more experience with it.

Thx . But plz tell how must look REGEXP?

0

you could generaste a searchable column by a simple character by charactor copy loop that would simply stop copying at a < and start again after the >! it could be done in an insert trigger in mysql 5+

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.