首先要从数据库读取数据,建议使用存储过程读取
set cmd = server.createobject(adodb.command)
with cmd
.activeconnection=conn
.commandtype=&h0004 '存储过程
.commandtext=guestbookpro
end with
dim resultrs, resultarray
set resultrs = cmd.execute(, null)
if not resultrs.eof then
resultarray = resultrs.getrows()
end if
set resultrs = nothing
set cmd = nothing
session(arr)=resultarray
哈哈,数据已经读出,接下来就该对数据进行分页显示了。。
page----当前页
frompage----页面开始记录位置
topage-----页面结束纪录位置
pagesize----每页显示的记录条数
n---记录总数
yushu-----最后一页的记录数
resultarray=session(arr)
n=ubound(resultarray,2)+1
pagesize=5
'response.write alert('&n&')
'response.write
yushu=n mod pagesize
if yushu=0 then
totalpage=fix(n/pagesize)
else
totalpage=fix(n/pagesize)+1
end if
if request(page)= then
page=1
else
page=int(request(page))
end if
if page>totalpage then
page=1
end if
if pagepage=totalpage
end if
frompage=(page-1)*pagesize
topage=frompage+pagesize-1
if yushu=0 then
frompage=(page-1)*pagesize
topage=frompage+pagesize-1
else
frompage=(page-1)*pagesize
topage=frompage+pagesize-1
if page=totalpage then
frompage=(page-1)*pagesize
topage=frompage+yushu-1
end if
end if
有什么地方说的不对,请多多指教
演示地址:http://fishbone31.w3.zccn.net
我这个网站因为上一页下一页刷新的都是整页,而非读取数据页[body.asp],所以速度不是很理想。
账号密码均为test