⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.asp

📁 这个论坛也不错.适合做毕业设计的
💻 ASP
字号:
<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="top.asp" -->
<table width=<%=TableWidth%> border =0 align="center" class="sft"><tr><td><a href="index.asp">论坛首页</a> > 搜索</td></tr></table>
<br>
<%
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), "</P><P>")
  String = Replace(String, CHR(10), "<BR>")
  FormatStr = String
End Function

If Request.QueryString("mode") = "doit" then

if Request.Form("search") <> "" then

keywords = split(Request.Form("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 Request.Form("forum") <> 0 then
	StrSql = StrSql & "Forum.Forum_ID = " & Request.Form("forum") & " and "
End If
StrSQL = StrSql & "("
if Request.Form("searchdate") <> 0 then
  dt = cint(Request.Form("searchdate"))
  StrSql = StrSql & "T_date > #" & dateadd("d", -dt, now) & "#) and ("
End if
cnt = 0
For Each word in keywords
  if Request.Form("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 "<center>错误:用户'" & word & "'不存在!<br></center>"
    StrSql =StrSql & "Topics.T_Originator = -1"
   else
    StrSql =StrSql & "Topics.T_Originator = " & rs2("member_id")
   end if
  end if
  if Request.Form("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 "<center>错误:用户'" & word & "'不存在!<br></center>"
    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 Request.Form("type")="s" then
    StrSql =StrSql & "Topics.T_Subject Like '%" & word & "%'"
  end if
  if Request.Form("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 &  Request.Form("andor") 
  cnt = cnt + 1
next 

StrSql =StrSql & ") order by topics.topic_id"
mypage=request("whichpage")
If mypage="" then
mypage=1
end if
Set rs= my_conn.Execute(StrSql)
If rs.Eof or rs.Bof then
	Response.Write "抱歉,没有找到相关内容."
Else

%>



<table align="center"  bgcolor=<%=TableColor%> border="0" width=<%=TableWidth%> cellspacing="1" cellpadding="3" class="sft" style='TABLE-LAYOUT: fixed'>
<tr><td align="center" bgcolor="<% =HeadColor %>" class="sfh" width="50%">帖子名称</td>
<td align="center" bgcolor="<% =HeadColor %>" class="sfh" width="20%">所在论坛</td>
<td align="center" bgcolor="<% =HeadColor %>" class="sfh" width="30%">发表时间</td></tr>

<%
rec_id=""
do until rs.Eof
  if not(rec_id = rs("topic_id")) then
    Response.Write "<td bgcolor='" & CellColor1 & "'><a href='Topic.asp?topic_id=" & rs("Topic_ID") & "&forum_id=" & rs("forum_id") & "&Topic_Title=" & rs("T_Subject") & "&forum_title=" & rs("f_name") & "'>"
    Response.Write rs("T_Subject") & "</a></td>"
    Response.Write "<td bgcolor='" & CellColor1 & "' align='center' valign='top'>" & rs("F_Name") &  "</td>"
    Response.Write "<td bgcolor='" & CellColor1 & "' align='center' valign='top'>" & rs("T_Date") & "</td>"
    Response.Write "</tr>"
  End if 
  rec_id = rs("topic_id")
  rs.MoveNext
loop
end If
else
Response.Write "<center>请输入关键字</center>"
Response.End
End if
Else
%>
<form action="Search.asp?mode=doit" method="post">
<br>
<table align="center" bgcolor=<%=TableColor%> border="0" width="620" cellspacing="1" cellpadding="3" class="sft">
<tr><td align="center" bgcolor="<%=HeadColor%>" colspan=2 class="sfh">搜 索</td></tr>
<tr><td bgcolor=<%=CellColor1%> align="right" width="20%">
搜索关键字: </td><td bgcolor=<%=CellColor1%> align="left" valign=top width="80%"><input type="text" name="search" size="36" class="box">(可以为多个,关键字间用空格分开)</td></tr>
<tr><td bgcolor=<%=CellColor1%> align="right">关键字性质:</td><td bgcolor=<%=CellColor1%>>
<input type="radio" name="type" value="a" checked>主题的作者<br>
<input type="radio" name="type" value="r" checked>主题或回复的作者<br>
<input type="radio" name="type" value="s">主题名称中的一部分<br>
<input type="radio" name="type" value="m">主题或内容中的一部分</td></tr>
<tr><td bgcolor=<%=CellColor1%> align="right">关键字关系:</td><td bgcolor=<%=CellColor1%>>
<input type="radio" name="andor" value=" and ">AND(内容必须包含所有关键字)<br>
<input type="radio" name="andor" value=" or "  checked>OR (内容可以只包含部分关键字)</td></tr>
<tr><td bgcolor=<%=CellColor1%> align="right">所在论坛: 
</td><td bgcolor=<%=CellColor1%> align="left" valign=top><select name="forum" class="box">
<option value="0">所有的论坛<%
StrSql = "SELECT * FROM Forum"
set rs = my_conn.execute (strSql)
On Error Resume Next
do until rs.eof
  Response.Write "<option value=""" & rs("forum_id") & """>" & left(rs("F_name"), 40) & "</option>" & vbcrlf
  rs.movenext
loop
%>  
</select></td></tr>
<tr><td bgcolor=<%=CellColor1%> align="right">发表时间:</td>
<td bgcolor=<%=CellColor1%> align="left" valign=top><SELECT NAME="SearchDate" class="box">
<OPTION value="0">所有时间
<OPTION VALUE="1">昨天至今
<OPTION VALUE="7" SELECTED>最近一周
<OPTION VALUE="14">最近两周
<OPTION VALUE="30">最近30天
<OPTION VALUE="100">最近100天
<OPTION VALUE="365">最近365天
</SELECT></td></tr></table>
<center><input type="submit" value="开始搜索" class="btn">
<br><br>提示:关键字关系为OR时,可以一次搜索多个作者或主题.此外,合理选择发表时间和所在论坛可以大大缩短搜索时间.
</center>
</form>
<% End If
on error resume next
set rs = nothing
set rs2 = nothing
my_conn.Close
set my_conn = nothing
%>
<!--#INCLUDE FILE="copyright.asp" -->
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -