Build site Search with ASP

Source: Internet
Author: User
Tags object key key words query
If you have a huge web site with a lot of content, it's often hard for visitors to find what they need, and then you need an in-site search to help visitors find the information they're looking for faster! Now you can use ASP easy to implement this function, not to mention now support ASP site so much, use this search engine can search your home page any a file or software information, it can be accurate to each word! Say so much you are not the heartbeat, Ah, then follow the steps to build your own search engine bar:

(i), First, use ACCESS97 to build a database called List.mdb, set up a table named list in the list, and then enter some file names you want to be queried, key search terms and corresponding links, four project IDs (numbering), title (subject), Word (key words), URLs (link addresses), as shown in the following table:

ID title Word URL
1 CGI tutorials Local debugging CGI cgi/testcgi.htm
2 Download Center chat room, message book download/index.htm

(b), the establishment of the database can be established after your ASP search page, the following is a file named search.htm ASP search page source program, this search engine can search the title and word inside the content, of course, if you need to build more search:


<% "Establish a database connection
con= "dbq=" +server.mappath ("List.mdb") + ";D efaultdir=;D irver={microsoft Access Driver (*.mdb)};"
"Create the Connection object and open the database
Set Mycon=server.createobject ("ADODB. CONNECTION ")
Mycon.open.con%>
"Create a routine for the Recordset object, open the Recordset object to pass the SQL string, and all connection information
<% set Rs=server.createobject ("ADODB. Recordset ")
Rs.Open "Select*form list where title and word like '% ' &request.form (" word ") &"% ", Mycon,adopenstatie
%>
"Create a query after the display of Information and query page, you want to take any name can




"The statistical query has a total of <% Response.Write (RS. RecordCount)%> Record






Id
Theme
View



<% While not rs.eof%>

<% =rs ("id")%>
<% =rs ("title")%>
">go
<% rs.movenext%><% Wend%> <% Rs.close%>
<% Mycon.close%>
The close link

Now let's build the search page.








OK, this station inside the search engine to even complete, what you have to do next is the entry of the database!

This article is organized by the beach Boy, you can reprint, but please be sure to indicate its origin and maintain its integrity, thank you!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.