这几天我写了一个分页的代码,刚开始把页面大小设为10,一共有两页,后来想改变为5,结果显示不了第二页以后的页面,而且第二页的开始还是页面大小为10时的第二页的开始记录。我的代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% Response.Buffer =True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "No-Cache" %>
<!--#include file="conn.asp" -->
<%
set rs=server.createobject("adodb.recordset")
sql="select * from admin"
rs.open sql,data,1,2
if rs.eof then
rs.close
response.write"没有相关记录!"
response.end
end if
do while not rs.eof
PageCount=PageCount+1
rs.movenext
loop
PageSize = 10
PageCount=(PageCount+PageSize-1)\PageSize
Page = CLng(Request("Page"))
If not Page >1 Then Page = 1
If Page > PageCount Then Page = PageCount
i=page+(page-1)*9
rs.AbsolutePage = Page
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>后台管理系统</title>
<link href="css/text.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="form2" method="post" action="">
<table width="100%" height="84" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#e2f0fb" class="TD">
<%For iPage = 1 To PageSize %>
<tr>
<td><div align="center"><%=rs("user_name")%></div></td>
<td><div align="center"><%=rs("admintel")%></div></td>
<td><div align="center"><%=rs("flag")%></div></td>
<td><div align="center"><%=rs("shenhe")%></div></td>
</tr>
<% rs.MoveNext
If rs.EOF Then Exit For
i=i+1
Next
%>
<%
rs.close
%>
</table>
</form>
<p></p>
<div ALIGN="right">
<table width="512" height="56" >
<form action="user_all.asp" method="GET">
<tr>
<td width="542" height="50"> <div align="right">
<%If Page <> 1 Then ' 如果不是位于第一页%>
<a href="user_all.asp?Page=1"> 第一页</a> <a href="user_all.asp?Page=<%=(Page-1)%>">
上一页</a>
<%
End If
If Page <> PageCount Then ' 如果不是位于最后一页
%>
<a href="user_all.asp?Page=<%=(Page+1)%>">下一页</a>
<a href="user_all.asp?Page=<%=PageCount%>">最后一页</a>
<% End If %>
<span class="ziti">输入页次:</span>
<input name="Page" size="3" class="s01">
<span class="ziti">页次:<%=Page%>/<%=PageCount%> </span></div>
<p></td>
</tr>
</form>
</table>
</div>
</div>
</td>
</tr>
</table>
那位高手帮我看看错误在那里,拜托拜托啦