<%
const MaxPerPage=14 '每页显示多少条记录
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
sql = "SELECT * FROM News order by id asc"
'SQL查询不用说了吧
set rs=server.createobject("adodb.recordset")
rs.open SQL,conn,1,1
rs.MoveFirst
rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'> ERROR!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
for i= 0 to howmanyfields
next
i=0
do while not rs.eof and i<maxperpage%>
<%=rs("title")%>
'里边写你要循环的内容
<%
i=i+1
rs.movenext
loop
%>
当前第 <%=currentpage%>页 共 <%=n%>页 <%=rs.recordcount%>
纪录
<%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 " [首页] [上一页] "
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 " [下一页] [尾页] "
end if
end if
rs.close
set rs=nothing
%>
欢迎你到我的博客一起讨论
www.