Forums

This topic is locked

Seaching a database

Posted 16 Aug 2004 17:03:38
1
has voted
16 Aug 2004 17:03:38 Mark Capric posted:
I need some major help on a project I'm trying to start with. I have an MS Access DB, I want to be able to have a html search engine that searches through the DB and then displays the results on another html page. Can someone tell me where I can started? Thanks for any help you can give.

Replies

Replied 16 Aug 2004 22:39:54
16 Aug 2004 22:39:54 Dave Thomas replied:
its not as hard as it sounds to do a search. its when you want to highlight and rank searches that it gets complicated.

basically you'll need a table in your database to search, but what is it your searching for? a title, something in the description, keywords???

you basically create a form with a textfield and a go button. call the textfield 'txtSearch' and have the action of the form set to 'search_results.asp' or something similiar. thats the first bit done.

now open 'search_results.asp' and create a recordset. You'll need to go into advanced SQL.

depending on what your searching for it will be along the lines of.

<pre id=code><font face=courier size=2 id=code>
SELECT * FROM tblArticles WHERE ArticleTitle LIKE '%" + Replace(rsNews__MMColParam, "'", "''" + "%' ORDER BY ArticleID DESC
</font id=code></pre id=code>

MMColParam is created by adding a varibale in the box with the value and run time string options and adding.
value = %
runtime string = Request.Form("txtSearch"

when that is set up, you add the data to the page via a table or whatever from the bindings panel, and you have a working search.

btw the % sign is a wildcard, there are a lot of ways to search for something, my example is just a basic search.

Regards,
Dave

[DWMX 2004]|[FlashMX 2004 Pro]|[SQL]|[Access2000]|[ASP/VBScript]|[XP-Pro]

Reply to this topic