<%
dim page_size
dim page_no
dim page_total
dim wenjianming
wenjianming="a.asp"
page_size=10
if request.querystring("page_no")="" then
page_no=1
else
page_no=cint(request.querystring("page_no"))
end if
rs.pagesize=page_size
page_total=rs.pagecount
if not(rs.bof or rs.eof) then
rs.absolutepage=page_no
end if
dim i
i=page_size
%>
<%
if page_total=1 then
response.write "首页|上一页|下一页|尾页"
else
response.write "<a href=" & wenjianming & "?page_no=1>首页</a>|"
if page_no-1>0 then
response.write "<a href=" & wenjianming & "?page_no=" & page_no-1 & ">上一页</a>|"
else
response.write "上一页|"
end if
if page_no+1<=page_total then
response.write "<a href=" & wenjianming & "?page_no=" & page_no+1 & ">下一页</a>|"
else
response.write "下一页|"
end if
response.write "<a href=" & wenjianming & "?page_no=" & page_total & ">尾页</a>"
end if
%>
<%
dim page_size
'声明变量这个应该是每页的从数据库中读取的纪录数
dim page_no
'这个变量应该是当前页的页码(也就是记录第几页的变量)
dim page_total
'总页数变量
dim wenjianming
wenjianming="a.asp"
page_size=10'设定每页读取10条数据库记录
if request.querystring("page_no")="" then
'判断当前页的页码,为空证明为第一页
page_no=1'设置为第一页
else
'不为空得到当前页码
page_no=cint(request.querystring("page_no"))
end if
rs.pagesize=page_size
'rs.pagesize设定RecordSet对象的pagesize属性该属性已经解释了
page_total=rs.pagecount
'rs.pagesize属性设定后rs.pagecount自动计算一共有多少页。
if not(rs.bof or rs.eof) then'防止错误如果数据库中有记录继续执行
rs.absolutepage=page_no'设定RecordSet对象的当前页
end if
dim i
i=page_size
%>
<%
'一下为翻页的代码防止翻页出错。
if page_total=1 then
response.write "首页|上一页|下一页|尾页"
else
response.write "<a href=" & wenjianming & "?page_no=1>首页</a>|"
if page_no-1>0 then
response.write "<a href=" & wenjianming & "?page_no=" & page_no-1 & ">上一页</a>|"
else
response.write "上一页|"
end if
if page_no+1<=page_total then
response.write "<a href=" & wenjianming & "?page_no=" & page_no+1 & ">下一页</a>|"
else
response.write "下一页|"
end if
response.write "<a href=" & wenjianming & "?page_no=" & page_total & ">尾页</a>"
end if
%>