Recommended: A function that analyzes ASP to check whether the website link is normal % FunctionurlChk(sUrl) onerrorresumenext SetxmlHttp=Server.CreateObject(Microsoft.XMLHTTP) xmlHttp.openGET,sUrl,false xmlHttp.send ifxmlHttp.Status200then urlChk=false else urlChk=true endif EndFunction sUrl=http://www.code-123.com ifu
It is very convenient to use ASP to implement the functions of search engines, but how to implement intelligent searches similar to 3721? For example, when Chinese people are entered in the search condition box, keywords such as China and people are automatically extracted from it and searched in the database. After reading this article, you can find that this function is so simple to implement.The first step is to create a database named db_sample.mdb (this article takes Access2000 database as an example), and create a table T_Sample.Table T_Sample includes the following fields:
Automatic ID numbering
U_Name text
U_Info Notes
In the second step, we start designing the search page Search.asp. The page includes a form (Frm_Search), which includes a text box and a submit button. And set the method property of the form to get and the action property to Search.asp, that is, submit it to the web page itself. The code is as follows:
| <!--Search.asp--> <formname=frm_Searchmethod=getaction=Search.asp> Please enter keywords: <inputtype=textname=keysize=10> <inputtype=submitvalue=search> </form> |
Next, we enter the key part of implementing intelligent search.
First, establish a database connection. Add the following code to the beginning of Search.asp:
| <% DimstrProvider,CNN strProvider=Provider=Microsoft.Jet.OLEDB.4.0;DataSource= strProvider=strProvider&Server.MapPath(/)&/data/db_Sample.mdb 'Suppose the database is stored in the data directory in the root directory of the home page SetCNN=Server.CreateObject(ADODB.connection) CNN.OpenstrProvider opens database connection %> |
Next, the data received by the ASP page is judged and searched in the database.
| <fontcolor=#FF0000>No results were found! ! ! </font> <% Else %> |
Search for items with the name <fontcolor=#FF0000><%=S_Key%></font>, and find a total of items with <fontcolor=#FF0000><%=RST.RecordCount%></font>:
| <% WhileNotRST.EOF traverses the entire record set, displays the searched information and sets the link %> <!-- Here you can set the link target you need--> <fontstyle=font:12pt安安><ahref=info.asp?ID=<%=RST(ID)%>target=_blank><%=RST(U_Name)%></a></font> <!--Show some details--> <fontstyle=font:9pt安><%=Left(RST(U_Info),150)%></font><p> <% RST.MoveNext Wend RST.Close SetRST=Nothing EndIf EndIf %> |
Share: ASP tutorial: Asp production of common flash news pictures rotation code This is a normal web page file html head metahttp-equiv=Content-Typecontent=text/html;charset=gb2312/ title News and picture rotation/title/head body !--#Includefile=diaoyong.asp-- /body /html Any web page just call the following file (diaoyong.asp), and the f used
2 pages in total Previous page 12 Next page