首页 详细查询虚拟主机 选机助手1.1 虚拟主机评测 免费虚拟主机 论坛
虚拟主机知识 站长工具 搜索优化(SEO) 建站技术 WEB服务器技术 开发日志
搜虚机

澳门 台湾 上海 广东 山东 福建 江苏 浙江 重庆 河北 河南 黑龙江 吉林 辽宁 内蒙古 海南 山西 陕西 安徽 江西 甘肃 新疆 湖北 湖南 云南 广西 宁夏 贵州 青海

  "钓爱搜索"热词: 100 100M 电信 jsp 网通 虚拟主机 虚拟主机 网通 双线 上海 电信 100M
收录家公司款主机!

免注册添加产品|免注册发布供求信息| 免费注册VIP| 登录

  asp简略地搜索引擎代码           ★★★ 【字体:
asp简略地搜索引擎代码
作者:佚名    文章来源:本站原创    点击数:    更新时间:2008-6-1    

下面是库中URLINDEX表:URL和Keywords字段分别添加了索引.

 URL           文本 (索引:有(无重复))
Title            文本
Description 文本
Summary    文本
Keywords   文本(索引:有(无重复))

doquery.ASP

 <HTML><HEAD><TITLE>简单搜索引擎</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   = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
 
 ' 如果搜索为空则返回
 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

 ' 查询语句
 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> 搜索的关键字: </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 语句 : </B> " & sql
 
 ' Print the Results
    Response.Write "<BR><B> 结果&nbsp;&nbsp;&nbsp;&nbsp;: </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 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    使用ASP建设私人的搜索引擎
    企业网站如何制定搜索引擎优
    搜索引擎必知十大秘技
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    ©2007-2008 SouXuji.com & HostDB.cn. All rights reserved. | 交换链接 | 广告赞助| 联系我们 | 站点地图
    Email:Souxuji@yahoo.com.cn 客服QQ:610413895

    网络收藏夹 航123自助链

    速搜全球 新新web2.0

     

    孙悟空 友情链接