<% sql = "select……………………省略了sql语句
set rs=server.createobject("adodb.recordset")
rs.open sql, conn, 1, 1
if not rs.eof then
pages = 30 ’定义每页显示的记录数
rs.pagesize = pages ’定义每页显示的记录数
allpages = rs.pagecount’计算一共能分多少页
page = request.querystring("page")’通过浏览器传递的页数
’if语句属于基本的排错处理
if isempty(page) or cint(page) < 1 then
page = 1
elseif cint(page) > allpages then
page = allpages
end if
rs.absolutepage = page
do while not rs.eof and pages > 0 %>
这里输出你要的内容………………
<% pages = pages - 1
rs.movenext
loop
else
response.write("数据库暂无内容!")
end if
rs.close
set rs = nothing %>
系统已经为数据分页了,下面就看看这次探讨的关键问题分页函数的定义
<% sub pageurl(purl)
dim eurl
txts = request.servervariables("url")
txts = left(txts,instrrev(txts,"/",len(txts))-1)
eurl = "http://"; & request.servervariables("server_name") & txts
for i =1 to allpages
txt = ""
txt = "<strong>"
txt = txt & "<a href=" & eurl & purl & "page="&i & ">"
if i = cint(page) then txt = txt & "<font color=’bb0000’>"
txt = txt & (i)
if i = cint(page) then txt = txt & "</font>"
txt = txt & "</a> ∥ </strong>"
response.write(txt)
next
end sub %>作者: wangjunping 时间: 2006-11-21 12:14