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!

Recommended Answers

All 7 Replies

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.

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:

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.

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.

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?

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+

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.