Source code of an ASP site search instance

Source: Internet
Author: User

If you have a large website (www.ehpos.com) with a large amount of content, it is often difficult for visitors to find what they need, at this time, you need a site search to help visitors quickly find the required information! Now you can use ASP to easily implement this function. Besides, there are so many websites that support ASP now. With this search engine, you can find any file or software on your homepage, it can be accurate to every word! If you say so much, are you still excited? follow the steps below to build your own search engine:
(1) first, use Access97 to create a list. create a table named list in the mdb database, and enter the names of the files you want to query in the List table. The key search words are linked accordingly, the following table lists four project IDS (numbers), title (topic), word (keyword), and URL (link address:
Id title word URL
1 CGI tutorial local debug CGI cgi/testcgi.htm
2 download center chat room, message book download/index.htm
(2) After creating a data library, you can create an ASP search page with a file named search.htm. the source code of the ASP search page can be searched by this search engine. Of course, you can create more searches if necessary:

<! -- # Include file = "adovbs. Inc" --> <% "Create a database connection
Con = "DBQ =" + server. mappath ("list. mdb ") +"; defaultdir =; dirver = {Microsoft Access Driver (*. MDB)}; "" create a connection object and open the database
Set mycon = server. Createobject ("ADODB. Connection") mycon. Open. Con %>
"Create A recordset object routine, 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 %>
"The displayed information and query page after the query are created. You can specify any name. <HTML> <Body bgcolor = "# ffffff"> <p align = "center"> <br>
"A total of <% response. Write (Rs. recordcount) %> records </P> <br> <Div align =" center "> <center>
<Table border = "1" align = "center" bordercolor = "000000" berdorcoorlight = "#000000" bordercolordark = "# ffffff"> <tr align = "center">
<TD width = "20%" align = "center" bgcolor = "# ffffff"> id </TD> <TD width = "60%" align = "center" bgcolor = "# ffffff "> topic </TD>
<TD width = "20%" align = "center" bgcolor = "# ffffff"> View </TD> </table> <Table border = "1" align = "center" bordercolor = "000000" berdorcoorlight = "#000000" bordercolordark = "# ffffff">
<Tr align = "center"> <! -- Extract information from the database -->
<% While not Rs. EOF %> <tr align = "center">
<TD width = "20%" align = "center" bgcolor = "# ffffff"> <% = RS ("ID ") %> </TD> <TD width = "60%" align = "center" bgcolor = "# ffffff"> <% = RS ("title") %> </TD>
<TD width = "20%" align = "center" bgcolor = "# ffffff"> <a href = "<% = RS (" url ") %> "> go </a> </TD> <% Rs. movenext %> </tr> <% Wend %> </table> </center> </div> <% Rs. close %>
<% Mycon. Close %> "close link
</Body>

<HTML> <From method = "Post" Action = "search. ASP "> <Div align =" center "> <center> <p> <input type =" text "name =" word "size =" 30 ">
<Input type = "Submit" value = "Submit" name = "B1"> <input type = "reset" value = "clear" name = "B2"> </P> </center> </div> </form>
<HR width = "600" align = "center"> <HTML> well, the search engine on this site is complete. What you need to do next is to enter the database.

 

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.