?? 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 + -