<!-- 分页功能代码块,可独立使用 -->
<%
const MaxPerPage=3 '单独页最大记录数 const 用来申明常量
dim totalPut '总记录
dim CurrentPage '当前页次
dim TotalPages '总页数
dim i
%>
<%
if not rs1.eof then
rs1.MoveFirst '注意放到前面来,否则到任何页总是在第一个记录上
end if
rs1.pagesize=MaxPerPage '设置每页最多显示多少条记录
If trim(Request("page"))<>"" then '如果请求的页次不为空
CurrentPage= CLng(request("page")) 'clng是转换成长整型数据类型,并赋值到当前页次上
If CurrentPage> rs1.PageCount then '如果当前页次大于总页数,则将最大页次赋值到当前页次上
CurrentPage = rs1.PageCount
End If
Else
CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If
totalPut=rs1.recordcount '将总记录赋值于TOTALPUT
if CurrentPage<>1 then '如果当前页数不等于第一页
if (currentPage-1)*MaxPerPage<totalPut then '如果当前页减一乘以每页最大的记录数小于总记录的话
rs1.move(currentPage-1)*MaxPerPage '相对当前记录数向后移动
dim bookmark '定义书签变量
bookmark=rs1.bookmark '将当前记录的标签赋于变量BOOKMARK上
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
%>
<table width="640" border="1" align="center" cellpadding="0" cellspacing="0">
<form action="message.asp" method="post">
<tr>
<td height="25" colspan="8" align="center" class="STYLE2">
<!-- 分页显示代码块 可独立使用,注意和上面分页功能代码配使用 -->
当前第<font color="#ff0000"><%=currentpage%></font>页 总共<font color="#FF0000"><%=n%></font>页 共<font color="#FF0000"><%=rs1.recordcount%></font>个留言
<%
k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='?page="&cstr(k-1)&"'>上一页</a></b>] "
else
Response.Write "<s>[首页] [上一页]</s>"
end if
if k<>n then
response.write "[<b>"+"<a href='?page="&cstr(k+1)&"'>下一页</a></b>] "
response.write "[<b>"+"<a href='?page="&cstr(n)&"'>尾页</a></b>] "
else
Response.Write "<s>[下一页] [尾页]</s>"
end if
%>
<input name="page" type="text" id="page" size="2" value="<%=currentPage%>">
<input name="Submit" type="submit" class="smallInput" value="转到"></td>
</tr>
</form>
</table>