下面是文章显示的代码:
信息列表dim conn dim connstr dim totalPut dim CurrentPage dim TotalPages dim i,j dim sql dim rs on error resume next '打开数据库 set rs=server.createobject("adodb.recordset") '定义每页文章显示数 const MaxPerPage=10 if not isempty(request("page")) then currentPage=cint(request("page")) else currentPage=1 end if sql="select * from news order by 置顶 desc,id desc" Set rs= Server.CreateObject("ADODB.Recordset") rs.open sql,conn,3,2 if rs.eof and rs.bof then response.write " 还 没 有 任 何 文 章 "else '数据库中文章数totalput totalPut=rs.recordcount if currentpage<1 then currentpage=1 end if '统计总页数currentpage if (currentpage-1)*MaxPerPage>totalput then if (totalPut mod MaxPerPage)=0 then currentpage= totalPut \ MaxPerPage else currentpage= totalPut \ MaxPerPage + 1 end if end if if currentPage=1 then showContent showpage totalput,MaxPerPage,"qtlist.asp" else if (currentPage-1)*MaxPerPage rs.move (currentPage-1)*MaxPerPage dim bookmark bookmark=rs.bookmark showContent showpage totalput,MaxPerPage,"qtlist.asp" else currentPage=1 showContent showpage totalput,MaxPerPage,"qtlist.asp" end if end if end if sub showContent '选择显示数据库内容 %>
i=0 j=0 do while not rs.eof %> | |||||||
target="_blank"> " " then%> |
签收完毕 签收中 |
'当显示记录大于maxperpage时结束这页
i=i+1
j=j+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
end sub
function showpage(totalnumber,maxperpage,filename)
'求出当总共的页数
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "
"response.write "
>>分页 "
'显示页数链接的条件
if CurrentPage<2 then
response.write "首页 上一页 "
else
response.write "首页 "
response.write "上一页 "
end if
if n-currentpage<1 then
response.write "下一页 尾页"
else
尾页"end if
response.write " 页次:"&CurrentPage&"/"&n&"页"
response.write " 共"&totalnumber&"篇文章 "&maxperpage&"篇文章/页"
response.write " 转到:"
response.write ""
response.write " 管理登陆
"end function
rs.close
set rs=nothing
conn.close
set conn=nothing
%>