如何做一个分页程序?
这在ASP中确实容易实现,但需要技巧,看看下面的分页代码和说明: on error resume next connstr=\Access Driver (*.mdb)};\ set conn=server.createobject(\ conn.open connstr set rs=server.createobject(\ ' 打开数据库 const MaxPerPage=18 ' 定义每页文章显示数 if not isempty(request(\ currentPage=cint(request(\ else currentPage=1 end if sql=\ Set rs= Server.CreateObject(\ rs.open sql,conn,1,1 if rs.eof and rs.bof then response.write \噢,还没有文章呢,正在添加中…
totalPut=rs.recordcount ' 数据库中文章数totalput 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
showpage totalput,MaxPerPage,\ showContent
showpage totalput,MaxPerPage,\ else
if (currentPage-1)*MaxPerPage bookmark=rs.bookmark showpage totalput,MaxPerPage,\ showContent showpage totalput,MaxPerPage,\ else currentPage=1 showpage totalput,MaxPerPage,\ showContent showpage totalput,MaxPerPage,\ end if end if rs.close end if set rs=nothing conn.close set conn=nothing sub showContent dim i i=0 do while not rs.eof > response.write \上一页 \ end if if n-currentpage<1 then response.write \下一页 尾页\ else response.write \ response.write \下一页 \ end ifc response.write \color='#000080'>页次;\页\ response.write \color='#000080'>共\篇文章 \篇文章/页 \ response.write \转到: class=smallInput value=\ response.write \class=buttonface name='cndok'>
type='submit' value='转到'