border =0 align="center" class="sft">
论坛首页 > 搜索

<% set my_conn= Server.CreateObject("ADODB.Connection") 'set rs = Server.CreateObject("ADODB.Recordset") my_Conn.Open ConnString Function FormatStr(String) on Error resume next String = Replace(String, CHR(13), "") String = Replace(String, CHR(10) & CHR(10), "

") String = Replace(String, CHR(10), "
") FormatStr = String End Function If Request.QueryString("mode") = "doit" then if Request.Form("forum")<>"" then forum = Request.Form("forum") else forum = Request.QueryString("forum") end if if Request.Form("search")<>"" then search = Request.Form("search") else search = Request.QueryString("search") end if if Request.Form("SearchDate")<>"" then SearchDate = Request.Form("SearchDate") else SearchDate = Request.QueryString("SearchDate") end if if Request.Form("search_type")<>"" then search_type = Request.Form("search_type") else search_type = Request.QueryString("search_type") end if if Request.Form("andor")<>"" then andor = Request.Form("andor") else andor = Request.QueryString("andor") end if if search <> "" then keywords = split(search, " ") keycnt = ubound(keywords) StrSql ="SELECT Forum.*, Reply.*, Topics.* FROM (Forum LEFT JOIN Topics " StrSql = StrSQl & "ON Forum.Forum_ID = Topics.Forum_id) LEFT JOIN Reply ON Topics.Topic_ID = Reply.Topic_ID " StrSQl = StrSql & "WHERE " if forum <> 0 then StrSql = StrSql & "Forum.Forum_ID = " & forum & " and " End If StrSQL = StrSql & "(" if searchdate <> 0 then dt = cint(searchdate) StrSql = StrSql & "T_date > #" & dateadd("d", -dt, now) & "#) and (" End if cnt = 0 For Each word in keywords if search_type="a" then StrSql2 ="SELECT Member_id FROM Members WHERE M_Name = '" & word & "'" Set rs2= my_conn.Execute(StrSql2) if rs2.Bof or rs2.Eof then Response.Write "

错误:用户'" & word & "'不存在!
" StrSql =StrSql & "Topics.T_Originator = -1" else StrSql =StrSql & "Topics.T_Originator = " & rs2("member_id") end if end if if search_type="r" then StrSql2 ="SELECT Member_id FROM Members WHERE M_Name = '" & word & "'" Set rs2= my_conn.Execute(StrSql2) if rs2.Bof or rs2.Eof then Response.Write "
错误:用户'" & word & "'不存在!
" StrSql =StrSql & "(Topics.T_Originator = -1 or R_Posted_By = -1)" else StrSql =StrSql & "(Topics.T_Originator = " & rs2("member_id") & " or R_Posted_By = " & rs2("member_id") & ")" end if end if if search_type="s" then StrSql =StrSql & "Topics.T_Subject Like '%" & word & "%'" end if if search_type="m" then StrSql =StrSql & "Topics.T_Subject Like '%" & word & "%' or Reply.R_Message Like '%" StrSql =StrSql & word & "%' or Topics.T_Message Like '%" StrSql =StrSql & word & "%' " end if if cnt < keycnt then StrSql = StrSql & andor cnt = cnt + 1 next StrSql =StrSql & ") order by topics.topic_id" set rs = server.CreateObject("ADODB.RecordSet") rs.Open strSql, my_conn, 1, 1 'Set rs= my_conn.Execute(StrSql) If rs.Eof or rs.Bof then Response.Write "抱歉,没有找到相关内容." Else %> border="0" width=<%=TableWidth%> cellspacing="1" cellpadding="3" class="sft" style='TABLE-LAYOUT: fixed'> <% rs.PageSize = ForumRow PageSize = rs.PageSize TotalPages=rs.PageCount page=Request.QueryString("page") if not IsNumeric(page) then page=1 if page>1 then page = cint(page) else page = 1 end if if page>TotalPages then page=TotalPages rs.AbsolutePage=page do until rs.Eof or RowCount>= PageSize if not(id = rs("topic_id")) then Response.Write "" Response.Write "" Response.Write "" Response.Write "" End if id = rs("topic_id") RowCount= RowCount+ 1 rs.MoveNext loop %>
帖子名称 所在论坛 发表时间
" Response.Write rs("T_Subject") & "" & rs("F_Name") &"" & rs("T_Date") & "
cellspacing="1" cellpadding="3" class="sft">
<% Response.Write "共" & TotalPages & "页" beginpage=1 endpage=Totalpages if TotalPages>=5 then if page>=3 then beginpage=page-2 if page<=(TotalPages-2) then endpage=page+2 else endpage=TotalPages beginpage=TotalPages-4 end if else beginpage=1 endpage=5 end if end if if beginpage>1 then response.write " <<" for i=beginpage to endpage if i=page then response.write " "&i&"" else response.write " "&i&"" end if next if endpage>>" %>
<% end if else Response.Write "
请输入关键字
" Response.End End if Else %>

border="0" width="620" cellspacing="1" cellpadding="3" class="sft">
搜 索
align="right" width="20%"> 搜索关键字: align="left" valign=top width="80%">(可以为多个,关键字间用空格分开)
align="right">关键字性质:> 主题的作者
主题或回复的作者
主题名称中的一部分
主题或内容中的一部分
align="right">关键字关系:> AND(内容必须包含所有关键字)
OR (内容可以只包含部分关键字)
align="right">所在论坛: align="left" valign=top>
align="right">发表时间: align="left" valign=top>


提示:关键字关系为OR时,可以一次搜索多个作者或主题.此外,合理选择发表时间和所在论坛可以大大缩短搜索时间.
<% End If on error resume next set rs = nothing set rs2 = nothing my_conn.Close set my_conn = nothing %>