|
我做了一个分页代码!!! 每页显示10条。为什么一超过10条就出错拉!错误如下:
错误类型:
Microsoft VBScript 运行时错误 (0x800A0009)
下标越界: '11'
/address/index.asp, 第 116 行
代码如下:
<%if not isempty(request("page")) then
page=cint(request("page"))
else
page=1
end if
set rs1=server.createobject("adodb.recordset")
sql1="select*from user"
rs1.open sql1,secondconn,1,1
if rs1.eof and rs1.bof then
response.write"<p align='center'>对不起,没有找到相关内容!</p>"
else
const maxperpage=10
rs1.pagesize=maxperpage
totalrecord=rs1.recordcount
totalpage=rs1.pagecount
if page>totalpage then page=totalpage end if
rs1.absolutepage=page
i=0
dim truename(),nickname(),quanxian(),email(),userlogincount()
do while not rs1.eof and (i<rs1.pagesize)
i=i+1
redim preserve truename(i),nickname(i),quanxian(i),email(i),userlogincount(i)
truename(i)=rs1("truename")
nickname(i)=rs1("nickname")
if rs1("quanxian")="master" then
quanxian(i)="班级管理员"
elseif rs1("quanxian")="member" then
quanxian(i)="班级成员"
else quanxian(i)="未审核"
end if
email(i)=rs1("email")
userlogincount(i)=rs1("logincount")
rs1.movenext
loop
end if
rs1.close
set rs1=nothing
%>
<%for i=1to totalrecord%>
<tr>
<td><span class="STYLE2"><%=i%></span></td>
<td><span class="STYLE2"><a href="detail.asp?name=<%=truename(i)%>" target="_blank"><%=truename(i)%></span></td>
<td><span class="STYLE2"><%=nickname(i)%></span></td>
<td><span class="STYLE2"><%=email(i)%></span></td>
<td><span class="STYLE2"><%=quanxian(i)%></span></td>
<td><span class="STYLE2"><%=userlogincount(i)%></span></td>
</tr><%next%>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td align="center">
<div align="center" class="font14">
共有<%=totalrecord%>条记录,
每页<%=maxperpage%>条,共<font color=red><%=totalpage%></font>页 第<%=page%>页
<%if page-1>0 then%>
<a href="index.asp?page=<%=page-1%>">上一页</a>
<%else%>上一页<%end if%>
<%if page+1<=totalpage then%>
<a href="index.asp?page=<%=page+1%>">下一页</a>
<%else%>
下一页
<%end if%>
</div> |
|