分页程序有点小问题
oomen 2006-11-25 02:07:09 平时基本上都用这个分页
<%
const maxperpage=20'每页的记录数
dim currentpage
objRS.pagesize=maxperpage
currentpage=request.querystring("pageid")
if currentpage="" then
currentpage=1
elseif currentpage<1 then
currentpage=1
else
currentpage=clng(currentpage)
if currentpage > objRS.pagecount then
currentpage=objRS.pagecount
end if
end if
if not isnumeric(currentpage) then
currentpage=1
end if
dim totalput,n
totalput=objRS.recordcount
if totalput mod maxperpage=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
if n=0 then
n=1
end if
objRS.move(currentpage-1)*maxperpage
i=0
do while i< maxperpage and not objRS.eof
Response.Write " <li> <A HREF='02.asp?id=" & objRS("id") & "'target='_blank'>" & left(objRS("tittle"),30) & " </A>"
Response.Write "("& objRS("time") &")<br></li>"
i=i+1
objRS.MoveNext
Loop
%>
<br><br>
页数:<%=currentpage%>/<% =n%>
<%k=currentpage
if k<>1 then%>
<a href="main08.asp?pageid=1">首页</a>
<a href="main08.asp?pageid=<%=k-1%>">上一页</a><font color="#FFFFFF">
<%else%>
首页 上一页
<%end if%>
<%if k<>n then%>
<a href="main08.asp?pageid=<%=k+1%>">下一页</a>
<a href="main08.asp?pageid=<%=n%>">尾页</a><font color="#FFFFFF">
<%else%>
下一页 尾页
<%end if%>
<span class="STYLE1">总纪录<span class="STYLE1"><%=totalput%>条</span></span></div>
<%
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
其他没有一点问题,但是当记录数为0时,就会出错,当记录数大于0时,一点问题也没有。