📄 queryresult.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="inc/char.asp" -->
<!-- #include file="inc/const.asp" -->
<!-- #include file="chkuser.asp" -->
<!--#include file="inc/theme.asp"-->
<%
'on error resume next
dim rs,sql
dim currentpage
dim totalrec
dim stype,pSearch,nSearch,keyword
dim searchboard,ordername
dim searchDateLimit
stats="搜索结果"
stype=request("stype")
pSearch=request("pSearch")
nSearch=request("nSearch")
keyword=trim(request("keyword"))
boardid=request("boardid")
if isempty(request("page")) or isNull(request("page")) or (request("page")="") then
currentPage=1
else
if isInteger(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
if err.number<>0 then
err.clear
currentPage=1
end if
end if
if stype<3 then
if not isInteger(boardid) then
Errmsg=Errmsg+"<br>"+"<li>版面id必须是整数。"
founderr=true
end if
if keyword="" then
Errmsg=Errmsg+"<br>"+"<li>必须输入查询关键字。"
founderr=true
end if
if cint(boardid)<1 then
searchboard=""
else
searchboard=" b.boardid="&boardid&" and "
end if
end if
call nav()
call headline(1)
if founderr then
call error()
else
call search()
if founderr then call error()
end if
call endline()
sub search()
'搜索多少天内帖子
searchDateLimit=30
if request("SearchDate")="ALL" then
searchday=" DATEDIFF('d',dateandtime,Now()) < "&SearchDateLimit&" and "
else
searchday=" DATEDIFF('d',dateandtime,Now()) < "&request("SearchDate")&" and "
end if
sql=""
set rs=server.createobject("adodb.recordset")
select case stype
case 1
select case nSearch
'搜索主题帖子作者
case 1
sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b inner join board on b.boardid=board.boardid where b.username='"&keyword&"' and "&guestlist&" "&searchboard&" "&searchday&" b.parentid=0 ORDER BY b.announceID desc"
ordername="搜索主题作者帖子"
'搜索回复帖子作者
case 2
sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b inner join board on b.boardid=board.boardid where b.username='"&keyword&"' and "&guestlist&" "&searchboard&" "&searchday&" b.parentid>0 ORDER BY b.announceID desc"
ordername="搜索回复作者帖子"
'两者都搜索
case 3
sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b inner join board on b.boardid=board.boardid where "&guestlist&" "&searchboard&" "&searchday&" b.username='"&keyword&"' ORDER BY b.announceID desc"
ordername="搜索主题和回复作者帖子"
end select
case 2
select case pSearch
'搜索主题关键字
case 1
sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b inner join board on b.boardid=board.boardid where "&guestlist&" "&searchboard&" "&searchday&" (" & translate(keyword,"topic") & ") ORDER BY b.announceID desc"
'搜索内容关键字
ordername="搜索主题"
case 2
sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b inner join board on b.boardid=board.boardid where "&guestlist&" "&searchboard&" "&searchday&" (" & translate(keyword,"body") & ") ORDER BY b.announceID desc"
'两者都搜索
ordername="搜索内容"
case 3
sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b inner join board on b.boardid=board.boardid where "&guestlist&" "&searchboard&" "&searchday&" (" & translate(keyword,"topic") & " or " & translate(keyword,"body") & ") ORDER BY b.announceID desc"
ordername="搜索主题和内容"
end select
case 3
sql="select top 50 b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where "&guestlist&" b.boardid=board.boardid ORDER BY b.announceID desc"
ordername="最新50帖"
end select
'response.write sql
if sql="" then
Errmsg=Errmsg+"<br>"+"<li>请指定查询条件。"
founderr=true
exit sub
end if
rs.open sql,conn,1,1
if err.number<>0 then
Errmsg=Errmsg+"<br>"+"<li>数据库出错,查询失败。"
founderr=true
else
if rs.eof and rs.bof then
Errmsg=Errmsg+"<br>"+"<li>没有找到您要查询的内容。"
founderr=true
else
totalrec=rs.recordcount
if currentpage<1 then
currentpage=1
end if
MaxAnnouncePerpage=Clng(MaxAnnouncePerpage)
if (currentpage-1)*MaxAnnouncePerPage>totalrec then
if (totalrec mod MaxAnnouncePerPage)=0 then
currentpage= totalrec \ MaxAnnouncePerPage
else
currentpage= totalrec \ MaxAnnouncePerPage + 1
end if
end if
if currentPage=1 then
call searchinfo()
else
if (currentPage-1)*MaxAnnouncePerPage<totalrec then
rs.move (currentPage-1)*MaxAnnouncePerPage
call searchinfo()
else
currentPage=1
call searchinfo()
end if
end if
call listPages3()
end if
end if
set rs=nothing
end sub
sub searchinfo()
%>
<table cellpadding=0 cellspacing=0 border=0 width="<%=tablewidth%>" align=center>
<tr><td><font color="<%=bodyfontColor%>">查询<%=searchDateLimit%>天内的帖子,<%=ordername%>共查询到<font color=<%=AlertFontColor%>><%=totalrec%></font>个结果</font>
</td>
</tr>
</table>
<table cellpadding=0 cellspacing=0 border=0 width="<%=tablewidth%>" bgcolor=<%=Tablebackcolor%> align=center>
<tr><td height=1>
</td>
</tr>
</table>
<TABLE bgColor="<%=Tablebackcolor%>" border=0 cellPadding=0 cellSpacing=0 width="<%=tablewidth%>" align=center>
<TBODY>
<TR>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD align=middle height=25 bgColor="<%=Tabletitlecolor%>" width=32><font color=<%=TableFontcolor%>>状态</font></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD align=middle bgColor="<%=Tabletitlecolor%>" width=*><font color=<%=TableFontcolor%>>主 题 (点心情符为开新窗浏览)</font></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD align=middle bgColor="<%=Tabletitlecolor%>" width=80><font color=<%=TableFontcolor%>>作 者 </font></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD align=middle bgColor="<%=Tabletitlecolor%>" width=64><font color=<%=TableFontcolor%>>回复/人气</font></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD align=middle bgColor="<%=Tabletitlecolor%>" width=195><font color=<%=TableFontcolor%>>作者 | 发表时间</font></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td></TR>
</TBODY></TABLE>
<table cellpadding=0 cellspacing=0 border=0 width="<%=tablewidth%>" bgcolor=<%=Tablebackcolor%> align=center>
<tr><td height=1>
</td>
</tr>
</table>
<%
do while not rs.eof
%>
<TABLE bgColor="<%=Tablebackcolor%>" border=0 cellPadding=0 cellSpacing=0 width="<%=tablewidth%>" align=center>
<TBODY>
<TR>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1 height=24></td>
<TD align=middle bgColor="<%=Tablebodycolor%>" width=32><font color=<%=TableContentcolor%>>
<%if rs("locktopic")=1 then%><img src=<%=picurl%>lockfolder.gif alt="本主题已锁定"><%else%><%if rs("child")>=10 then%><img src=<%=picurl%>hotfolder.gif><%else%><img src=<%=picurl%>folder.gif><%end if%><%end if%></font>
</TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD bgColor=<%=Tablebodycolor%> width=*><font color=<%=TableContentcolor%>><a href='dispbbs.asp?boardID=<%=rs("boardID")%>&RootID=<%=rs("RootID")%>&ID=<%=rs("announceID")%>&skin=1' target=_blank><img src='<%=faceurl%><%if instr(rs("Expression"),facename)>0 then%><%=rs("Expression")%><%else%>face1.gif<%end if%>' border=0 alt="开新窗口浏览此主题"></a> <a href='dispbbs.asp?boardID=<%=rs("boardID")%>&RootID=<%=rs("RootID")%>&ID=<%=rs("announceID")%>'><%if rs("topic")="" then%><%=left(htmlencode(replace(rs("body"),chr(10)," ")),26)%>...<%else%><%=htmlencode(rs("topic"))%><%end if%></a></font> </TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD align=middle bgColor="<%=Tablebodycolor%>" width=80><font color=<%=TableContentcolor%>><a href="javascript:openScript('dispuser.asp?name=<%=htmlencode(rs("username"))%>',350,300)"><%=htmlencode(rs("username"))%></a></font></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD align=middle bgColor="<%=Tablebodycolor%>" width=64><font color=<%=TableContentcolor%>><%=rs("child")%>/<%=rs("hits")%></font></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td>
<TD bgColor=<%=Tablebodycolor%> width=195><font color=<%=TableContentcolor%>>
<%=FormatDateTime(rs("dateandtime"),2)%> <%=FormatDateTime(rs("dateandtime"),4)%>
<font color="<%=alertfontcolor%>">|</font>
<a href="javascript:openScript('dispuser.asp?name=<%=htmlencode(rs("username"))%>',350,300)"><%=htmlencode(rs("username"))%></a>
</FONT></TD>
<td bgcolor=<%=Tablebackcolor%> valign=middle width=1></td></TR>
</TBODY></TABLE>
<table cellpadding=0 cellspacing=0 border=0 width="<%=tablewidth%>" bgcolor=<%=Tablebackcolor%> align=center>
<tr><td height=1>
</td>
</tr>
</table>
<%
i=i+1
if i>=MaxAnnouncePerPage then exit do
rs.movenext
loop
rs.close
end sub
sub listPages3()
dim n
if totalrec mod MaxAnnouncePerPage=0 then
n= totalrec \ MaxAnnouncePerPage
else
n= totalrec \ MaxAnnouncePerPage+1
end if
%>
<script language="Javascript">
function viewPage(ipage){
document.frmList2.Page.value=ipage
document.frmList2.submit()
}
</script>
<table border="0" cellpadding="0" cellspacing="3" width="<%=tablewidth%>" align="center">
<form method="post" action="queryresult.asp" name="frmList2">
<tr>
<td valign="middle" nowrap><font color="<%=bodyfontColor%>">页次:<b><%=currentPage%></b>/<b><%=n%></strong>页 每页<b><%=MaxAnnouncePerPage%></b> 总贴数<b><%=totalrec%></b></td>
<td valign="middle" nowrap><font color="<%=bodyfontColor%>">
<div align="right"><p>分页:
<%
for p=1 to n
if p<10 then
if p=currentPage then
response.write "["+Cstr(p)+"] "
else
response.write "<a href='javascript:viewPage("+Cstr(p)+")' language='javascript'>["+Cstr(p)+"]</a> "
end if
end if
next
%>
<span class="smallFont">转到:<input type="text" name="Page" size=3 maxlength=10 value="<%=currentpage%>"><input type="button" value="Go" language="javascript" onclick="viewPage(document.frmList2.Page.value)" id="button1" name="button1"></span></p>
</div> </font>
</td>
</tr>
<input type="hidden" name="stype" value="<%=stype%>">
<input type="hidden" name="pSearch" value="<%=pSearch%>">
<input type="hidden" name="nSearch" value="<%=nSearch%>">
<input type="hidden" name="keyword" value="<%=keyword%>">
<input type="hidden" name="SearchDate" value="<%=request("SearchDate")%>">
<input type="hidden" name="BoardID" value="<%=BoardID%>">
</form>
</table>
<% if err.number<>0 then err.clear
end sub
%>
<!--#include file="footer.asp"-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -