一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

最简化分页程序,附源代码

时间:2008-01-18 编辑:简简单单 来源:一聚教程网

pagetest.asp 表现页面


<%
strSql = "select * from authors"
set rs=server.CreateObject("ADODB.RecordSet")
rs.open strSql,conn,1,1
set page = new PageBase
page.pagesize = 3
if not isnumeric(request("page")) then
page.currentpage=1
else
if (cint(request("page")<1)) then
page.currentpage=1
else
page.currentpage=request("page")
end if
end if
page.linkurl="pagetest.asp"
page.show(rs)
page.FenYe(rs)
%>
object.asp 页对象
<%
'***********************************
'*
'* 尼德类
'*
'* 主要有:分页类。。。。。
'*
'* coolwind QQ :1294420
'*
'***********************************
class PageBase
dim pagesize '每页显示的记录数
dim currentpage'当然页面数
dim linkurl '链结URL
sub show(oRs)
'显示分页符号的子程序---------------------------------------------------------------
i=0
rs.Move pagesize*(currentpage-1)
do while not oRs.eof and i response.write oRs(1)&"
"
i=i+1
oRs.movenext
loop
End sub
'显示分页符号的子程序---------------------------------------------------------------
sub FenYe(oRs)
totalput = oRs.recordcount
pagesum = totalPut PageSize
'如果是第一页
response.write "第"¤tpage&"页/共"&pagesum&"页"
maxpage = 0
minpage = 0
if((currentpage-5)>1) then
minpage = currentpage-5
if (currentpage+4)>pagesum then
maxpage = pagesum
else
maxpage = currentpage+4
end if
else
minpage = 1
if pagesum>10 then
maxpage = 10
else
maxpage = pagesum

热门栏目