Link to home
Start Free TrialLog in
Avatar of andris333
andris333

asked on

HTML search engine


I have a table with html formatted text data in one of the columns. Now I need to make a search using this field. The problem is that in this field is html mixed with text. So, if a user would search for a words like form or title, simple sql searches (SELECT * FROM TABLE_DATA WHERE BODY LIKE "%searchword%" ) will always return all records from database.

Maybe it sound supid, but does anyone know the way how to make search excluding specific database column html tags or this is not possible at all?
Avatar of rockmansattic
rockmansattic

I think this will help you

http://www.dbazine.com/celko9.html

Rockman
change this:

"%searchword%"

to this:

'"%&searchword&%"'

This is assuming you are storing your

request.form("...") in the variable called searchword
First of all, you shouldnt be Selecting all the fields on the search engine page, unless you really plan on showing all of them. Lets say its a book DBase. I would just display the title and author of the book and use the ISDN to know which record the user will eventually select.

SQL =  "SELECT ISDN, Title, Author FROM Books WHERE Title LIKE '%" + txtSearch + "%'"       for javascript
SQL =  "SELECT ISDN, Title, Author FROM Books WHERE Title LIKE '%" & txtSearch & "%'"      for VBscript

This select statement should only search in the Title field and not in any other field. If the recordset is returning the whole database then there's something wrong with your SQL statement. Try printing it on the screen with Response.Write(SQL). Also, look are your fields and your information and see if there's a way to narrow the search with dates or any other information the user is able to give you. Also if you're using Access to manage your database, you can test your SQL statement by making a query, however, you will have to change the % with *.

Hope this helps, good luck on your project.
Ivan
SOLUTION
Avatar of rockmansattic
rockmansattic

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
Avatar of andris333

ASKER


Rockman is correct.

My problem is with HTML inserted in fiields. For instance, a database field has following data:

<table><tr><td>this is the test</td></tr></table>

So if user searches for the word table, this particular record would show up in the results.

Btw, Rockman, I analyzed your solution and I don't understand: does it mean that I should make searchword list for every document in database? How could something like this could be done if I don't know what kind on keyword users might use?
ASKER CERTIFIED SOLUTION
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