|
|
 |
<%
set rs=server.createobject("adodb.recordset")
sql="select * from book order by id desc"
rs.open sql,conn,1,1
const MaxPerPage=5
page=request("page")
if page<>empty and page<>"" then
'检测输入页数是否合法
pagestrlong=len(page)
chOK="0123456789"
chvalid=true
j=1
do while j<=pagestrlong
ch=mid(page,j,1)
If instr(chOK,ch)=0 then
chvalid=false
exit do
end if
j=j+1
loop
'检测完毕
if not chvalid then '如果不合法
currentPage=1 '默认为第1页
else
currentPage=int(page) '如果合法则取整数
if currentpage=0 then '如果是0页取1
currentpage=1
end if
end if
else
currentPage=1 '如果空白测取第1页
end if
if rs.eof and rs.bof then
response.write "没有问题!"
showpages
else
totalPut=rs.recordcount '记录总数
'判断最大显示页数
if totalput<=maxperpage then
maxpagenum=1
else
pageys=totalput/maxperpage
if pageys > int(pageys) then
maxpagenum=int(pageys)+1
else
maxpagenum=int(pageys)
end if
end if
if currentPage=1 then
showContent
showpages
else
if (currentPage-1)*MaxPerPage>=totalPut then
currentPage=maxpagenum
end if
rs.move (currentPage-1)*MaxPerPage
showContent
showpages
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
%>
<%
i=1
do while not (rs.eof or err)
if rs("xm")<>"" then
xm=replace(replace(replace(replace(replace(replace(rs("xm"),"&","&"),"<","<"),">",">"),chr(13)," "),chr(34),"""),chr(32)," ")
else
xm=""
end if
xb=rs("xb")
if rs("size")>0 then
txstr="图像"
else
txstr="图像"
end if
if rs("xx")="" then
xxstr="信箱"
else
xxstr="信箱"
end if
if rs("zy")="" or trim(rs("zy"))="http://" then
zystr="主页"
else
zystr="主页"
end if
if rs("nr")<>"" then
nr=replace(replace(replace(replace(replace(replace(rs("nr"),"&","&"),"<","<"),">",">"),chr(13)," "),chr(34),"""),chr(32)," ")
else
nr=""
end if
sj=rs("sj")
if rs("hf")<>"" then
hf=replace(replace(replace(replace(replace(replace(rs("hf"),"&","&"),"<","<"),">",">"),chr(13)," "),chr(34),"""),chr(32)," ")
else
hf=""
end if
hfsj=rs("hfsj")
ip=rs("ip")
Response.Write ""
Response.Write "| "&xm&"("&xb&")  | "
Response.Write ""&txstr&" "&xxstr&" "&zystr&" | "
Response.Write ""&sj&" | "
Response.Write "| "&nr&" | "
if rs("hf")<>"" then
Response.Write "| 管理员回复:" & hf & " | "
end if
Response.Write " "
i=i+1
if i>MaxPerPage then exit do '循环时如果到尾部则先退出,如果记录达到页最大显示数,也退出
rs.movenext
loop
%>
|
<%
end sub
sub showpages()
%>
<%
end sub
%>
|
|
|