送你一个简单的,自己拿回去对照着研究吧.
<%
on error resume next
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from 表名 order by id desc"
rs.open sql,conn,3,1
if rs.eof then
response.Write "当前数据库中无记录!"
response.end
else
const maxperpage=20 '定义每一页显示的数据记录的常量
dim currentpage '定义当前页的变量
rs.pagesize=maxperpage
currentpage=request.querystring("pageid")
if currentpage="" or currentpage<1 then
currentpage=1
else
currentpage=clng(currentpage)
end if
if currentpage > rs.pagecount then
currentpage=rs.pagecount
end if
'如果变量currentpage的数据类型不是数值型
'将1赋给变量currentpage
if not isnumeric(currentpage) then
currentpage=1
end if
dim totalput,n '定义变量
totalput=rs.recordcount
if totalput mod maxperpage=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
if n=0 then
n=1
end if
rs.move(currentpage-1)*maxperpage
i=0
do while i< maxperpage and not rs.eof
%>
'这里是要显示的内容
<%
i=i+1
rs.movenext
loop
end if
%>
'简单的分页代码(只需要更改一下超链地址)
<td colspan="10" class="tdbg2">页数:<%=currentpage%>/
<% =n%>
<%k=currentpage
if k<>1 then%>
[<a href="exper.asp?pageid=1">首页</a>] [<a href="exper.asp?pageid=<%=k-1%>">上一页</a>]
<%else%>
[首页] [上一页]
<%end if%>
<%if k<>n then%>
[<a href="exper.asp?pageid=<%=k+1%>">下一页</a>] [<a href="exper.asp?pageid=<%=n%>">尾页</a>]
<%else%>
[下一页] [尾页]
<%end if%>
共有<font color="red"><%=totalput%></font>条记录
</td>