不用组件的简单分页
类别: ASP教程
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
cnpath="data source=" & server.MapPath("question.mdb")
conn.open "provider=microsoft.jet.oledb.4.0;" & cnpath
rs.open "bbs",conn,3,3
set rs=conn.execute("select * From mytable")
do until rs.eof
tatalrecord=tatalrecord+1
rs.movenext
loop
num=tatalrecord Mod 15
if num>0 then
i=1
else
i=0
end if
tatalpage=int(tatalrecord/15+i)
rs.movefirst
page=request.querystring("page")
if page="" then
page=1
end if
if not rs.eof then
if page=1 then
rs.movefirst
else
rs.move((page-1)*15)
end if
for iPage=1 to 15
if rs.eof then
exit for
response.end
end if
rs("xxxxx")
rs.movenext
next
end if
if page=1 then %>
<a href="bbs.asp?page=<%=page+1%>">下一页</a>
<a href="bbs.asp?page=<%=tatalpage%>">尾页</a>
<%
elseif int(page)=int(tatalpage) then
%>
<a href="bbs.asp?page=1">首页</a>
<a href="bbs.asp?page=<%=page-1%>">上一页</a>
<%else %>
<a href="bbs.asp?page=1">首页</a>
<a href="bbs.asp?page=<%=page-1%>">上一页</a>
<a href="bbs.asp?page=<%=page+1%>">下一页</a>
<a href="bbs.asp?page=<%=tatalpage%>">尾页</a>
<%
end if %>
共<b><%=tatalrecord %></b>条记录 第<b><%=page%>/<%=tatalpage% ></b>页 每页<b>15</b>条记录
<form action="bbs.asp" style="position: relative">
<p align="right">
跳转到第<input type="text" name="page" size="4">页<input type="submit" value="确定" name="B1" style="border-style: solid">
</form>
set rs=server.CreateObject("adodb.recordset")
cnpath="data source=" & server.MapPath("question.mdb")
conn.open "provider=microsoft.jet.oledb.4.0;" & cnpath
rs.open "bbs",conn,3,3
set rs=conn.execute("select * From mytable")
do until rs.eof
tatalrecord=tatalrecord+1
rs.movenext
loop
num=tatalrecord Mod 15
if num>0 then
i=1
else
i=0
end if
tatalpage=int(tatalrecord/15+i)
rs.movefirst
page=request.querystring("page")
if page="" then
page=1
end if
if not rs.eof then
if page=1 then
rs.movefirst
else
rs.move((page-1)*15)
end if
for iPage=1 to 15
if rs.eof then
exit for
response.end
end if
rs("xxxxx")
rs.movenext
next
end if
if page=1 then %>
<a href="bbs.asp?page=<%=page+1%>">下一页</a>
<a href="bbs.asp?page=<%=tatalpage%>">尾页</a>
<%
elseif int(page)=int(tatalpage) then
%>
<a href="bbs.asp?page=1">首页</a>
<a href="bbs.asp?page=<%=page-1%>">上一页</a>
<%else %>
<a href="bbs.asp?page=1">首页</a>
<a href="bbs.asp?page=<%=page-1%>">上一页</a>
<a href="bbs.asp?page=<%=page+1%>">下一页</a>
<a href="bbs.asp?page=<%=tatalpage%>">尾页</a>
<%
end if %>
共<b><%=tatalrecord %></b>条记录 第<b><%=page%>/<%=tatalpage% ></b>页 每页<b>15</b>条记录
<form action="bbs.asp" style="position: relative">
<p align="right">
跳转到第<input type="text" name="page" size="4">页<input type="submit" value="确定" name="B1" style="border-style: solid">
</form>
- 上一篇: ASP在线压(缩)解(压)RAR
- 下一篇: 两个控制显示格式的函数(自动换行、自动省略)
-= 资 源 教 程 =-
文 章 搜 索