%
const MaxPerPage=6 '单独页最大记录数 const 用来申明常量
dim sql
dim rs
dim totalPut '总记录
dim CurrentPage '当前页次
dim TotalPages '总页数
dim i
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from book where shenhe=1 order by istop,id desc"
rs.open sql,conn,1,1
dim filename
filename="index.asp"
%>
<%
if rs.eof and rs.bof then
%>
暂时还没有任何留言!
<%
response.end
end if
%>
<%
if not rs.eof then
rs.MoveFirst '注意放到前面来,否则到任何页总是在第一个记录上
end if
rs.pagesize=MaxPerPage '设置每页最多显示多少条记录
If trim(Request("Page"))<>"" then '如果请求的页次不为空
CurrentPage= CLng(request("Page")) 'clng是转换成长整型数据类型,并赋值到当前页次上
If CurrentPage> rs.PageCount then '如果当前页次大于总页数,则将最大页次赋值到当前页次上
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If
totalPut=rs.recordcount '将总记录赋值于TOTALPUT
if CurrentPage<>1 then '如果当前页数不等于第一页
if (currentPage-1)*MaxPerPage
<%
id=(totalPut-MaxPerPage*(currentPage-1))+1
i=0
Do While Not rs.EOF and i
当前第<%=currentpage%>页 总共<%=n%>页 共<%=rs.recordcount%>个留言
<%k=currentPage
if k<>1 then
response.write "["+"首页] "
response.write "["+"上一页] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "["+"下一页] "
response.write "["+"尾页] "
else
Response.Write "[下一页] [尾页]"
end if
%>
管理留言
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>