Recommended: ASP integrates a SQL statement class When writing an asp database program, we usually use SQL statements, and when adding and updating data, we usually use the following method: insert into message (incept,sender,title,content,sendtime,flag,issend) values ('incept(i)','membername','title','message',Now(),0,1) When there are many fields
If you have a huge website and lots of content, it is often difficult for visitors to find what they need. At this time, you need a website search to help visitors find the information they are looking for faster! Now you can easily implement this function with asp, not to mention that there are so many sites that support asp. You can use this search engine to search any file or software information in your homepage, and it can accurately reach every word! After saying so much, are you feeling moved? Then follow the steps below to build your own search engine:
(1) First, use access97 to create a database named list.mdb, create a table called list, and then enter some file names you want to be queryed in the list table. The key search terms also have corresponding links. Four project IDs (numbers), title (theme), Word (keyword), and url (link address), as shown in the following table:
(2) After establishing the database, you can create your asp search page. The following is the source program of the asp search page with the file name search.htm. This search engine can search for content in title and word at the same time. Of course, if you need it, you can create more searches:
<!--#INCLUDE file=ADOVBS.inc-->
<% Establish a connection to the database
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 routine for 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 the display information and query page after query. You can choose any name you want.
<html><head><title>Query results</title></head>
<body bgcolor=#ffffff>
<p align=center><br>
Statistical query has 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 the link
</body></html>
Let's create a search page
<html><head><title>Search page</title></head>
<!--Create a search form-->
<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>
Okay, this site search engine is completed here, and the next thing you have to do is enter the contents into the database!
This article is compiled by the Beach Boy. You can reprint it, but please be sure to indicate its source and maintain its integrity. Thank you!
Share: ASP template code Class Template Private m_FileName, m_Root, m_Unknowns, m_LastError, m_HaltOnErr Private m_ValueList, m_BlockList Private m_RegExp Private Sub Class_Initialize Set m_ValueList = CreateObject(Scripting.Dictionary) Set m_BlockList = CreateObject(Script