<td class="mainborder"> <%
const MaxPerPage=20 '单独页最大记录数 const 用来申明常量
dim sql
dim rs
dim totalPut '总记录
dim CurrentPage '当前页次
dim TotalPages '总页数
dim i
dim bigclass,smallclass,keyword
bigclass=request("bigclassname")
smallclass=request("smallclassname")
keyword=Trim(request("keyword"))
sql="select * from qgsinfo "
if smallclass<>""then
sql=sql&"where bigclassname='"&bigclass&"'and smallclassname='"&smallclass&"' "
elseif bigclass<>""then
sql=sql&"where bigclassname='"&bigclass&"' "
else
sql=sql&"where cp like '%"&keyword&"%'"
end if
sql=sql&"order by id desc"
set rs=Server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
if not rs.eof then
'分页功能代码块,可独立使用
rs.MoveFirst '注意放到前面来,否则到任何页总是在第一个记录上
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<totalPut then '如果当前页减一乘以每页最大的记录数小于总记录的话
rs.move(currentPage-1)*MaxPerPage '相对当前记录数向后移动
dim bookmark '定义书签变量
bookmark=rs.bookmark '将当前记录的标签赋于变量BOOKMARK上
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1