小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

asp簡(jiǎn)單的搜索引擎代碼

 suncly 2006-05-11
 
asp簡(jiǎn)單的搜索引擎代碼

作者:淘特網(wǎng)

出處:http://www.

注:轉(zhuǎn)載請(qǐng)注明出處

下面是庫(kù)中URLINDEX表:URL和Keywords字段分別添加了索引.

 URL           文本 (索引:有(無(wú)重復(fù)))
Title            文本
Description 文本
Summary    文本
Keywords   文本(索引:有(無(wú)重復(fù)))

doquery.asp

 <HTML><HEAD><TITLE>簡(jiǎn)單搜索引擎</TITLE></HEAD>
<BODY BGCOLOR=#ffffff MARGINWIDTH="0" MARGINHEIGHT="0"
LEFTMARGIN=0 TOPMARGIN=0>

<FORM METHOD="post" ACTION="doquery.asp?act=search">
 Query: <INPUT TYPE="Text" NAME="QueryString"><BR>
 <INPUT TYPE="Submit" VALUE="Submit">
</FORM>
</CENTER>


<%
dim act
act=request("act")
if(act="search") then
 QueryString = Request.form( "QueryString" )
 QueryWords  = Split( QueryString )
 strIndent   = "          "
 
 ‘ 如果搜索為空則返回
 If QueryString = "" Then
  Response.Redirect( "default.asp" )
 End If
 
 Session.timeout = 2
 If IsObject(Session("sitesearch_conn")) Then
     Set conn = Session("sitesearch_conn")
 Else
     Set conn = Server.CreateObject("ADODB.Connection")
     conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("database/SiteSearch.mdb"),"",""
     Set Session("sitesearch_conn") = conn
 End If

 ‘ 查詢(xún)語(yǔ)句
 sql = "SELECT * FROM [URLIndex] WHERE"
   


 ‘搜索Description字段
 sql = sql & " ( [Description] LIKE ‘%" & QueryWords( 0 ) & "%‘"   ‘ First
 For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
  If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
   If uCase( QueryWords( i-1 ) ) = "OR" Then
    sql = sql & " OR [Description] LIKE ‘%" & QueryWords( i ) & "%‘"
   Else
    sql = sql & " AND [Description] LIKE ‘%" & QueryWords( i ) & "%‘"
   End If
  End If
 Next

 ‘ 搜索Keywords字段
 sql = sql & " ) OR ( [Keywords] LIKE ‘%" & QueryWords( 0 ) & "%‘"
 For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
  If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
   If uCase( QueryWords( i-1 ) ) = "OR" Then
    sql = sql & " OR [Keywords] LIKE ‘%" & QueryWords( i ) & "%‘"
   Else
    sql = sql & " AND [Keywords] LIKE ‘%" & QueryWords( i ) & "%‘"
   End If
  End If
 Next


 ‘  搜索Title字段 
 sql = sql & " ) OR ( [Title] LIKE ‘%" & QueryWords( 0 ) & "%‘"
 For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
  If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
   If uCase( QueryWords( i-1 ) ) = "OR" Then
    sql = sql & " OR [Title] LIKE ‘%" & QueryWords( i ) & "%‘"
   Else
    sql = sql & " AND [Title] LIKE ‘%" & QueryWords( i ) & "%‘"
   End If
  End If
 Next


 ‘ 搜索Summary字段
 sql = sql & " ) OR ( [Summary] LIKE ‘%" & QueryWords( 0 ) & "%‘"
 For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
  If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
   If uCase( QueryWords( i-1 ) ) = "OR" Then
    sql = sql & " OR [Summary] LIKE ‘%" & QueryWords( i ) & "%‘"
   Else
    sql = sql & " AND [Summary] LIKE ‘%" & QueryWords( i ) & "%‘"
   End If
  End If
 Next

 sql = sql & " )"


    ‘
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sql, conn, 3, 3    
   
    Response.Write "<BR><B> 你搜索的是: </B> " & QueryString   
   
    Response.Write "<BR><B> 搜索的關(guān)鍵字: </B> "
 For i = LBound( QueryWords ) to UBound( QueryWords )
  Response.Write "<BR>" & strIndent & i & ": " & QueryWords( i )
 Next

    ‘ Print the SQL String
    Response.Write "<BR><B> sql 語(yǔ)句 : </B> " & sql
 
 ‘ Print the Results
    Response.Write "<BR><B> 結(jié)果    : </B> <UL>"
 On Error Resume Next
 rs.MoveFirst
 Do While Not rs.eof
  Response.Write "<BR>" & "<A HREF=‘OpenPage.asp?IndexURL=" & rs.Fields("URL").Value & "‘>" & rs.Fields("Title") & "</A> - "
  Response.Write rs.Fields("Description") & "<BR>"
  Response.Write "     <FONT SIZE=2>URL: " & rs.Fields("URL") & "</FONT>"
  Response.Write "<HR SIZE=1 WIDTH=200 ALIGN=LEFT>"
  rs.MoveNext
 Loop
 Response.Write "</UL>"
 
end if  
%>


</BODY>
</HTML>

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多