1. 程式人生 > >asp數據分頁顯示技術(上下頁版)

asp數據分頁顯示技術(上下頁版)

IT then write req add resp 當前 select esc

<%set rs=server.CreateObject("adodb.recordset")
sql="select * from [student_admin] order by id DESC"
rs.open sql,conn,1,3
%>
<%
rs.pagesize=15‘這個是顯示最新的8條記錄,可以按自己需要改
curpage=Request.QueryString("curpage")‘記錄頁碼數
if curpage="" then curpage=1‘如果為空就讓它為1,不可能要它0頁嘛
if rs.bof and rs.eof then‘判斷數據庫有沒有記錄,沒有就下面
response.Write("")
else
rs.AbsolutePage=curpage ‘記錄當前頁碼
for i= 1 to rs.pagesize‘循環,從1到當前頁碼
if rs.eof then‘如果到最後一條記錄,退出循環
exit for
end if
%>
內容......................................
<%
rs.movenext
if rs.eof then
exit for
end if
next
%>
<div align="center" class="STYLE4" style="height:35px; padding-top:10px">
共有<%=rs.pagecount%>頁,當前第<%=curpage%>頁
<%if curpage=1 then%>首頁<%else%><a href="?curpage=1">首頁</a><%end if%>
<%if curpage<>1 then%><a href="?curpage=<%=curpage-1%>">上一頁</a><%end if%>
<%if rs.pagecount>=curpage+1 then%><a href="?curpage=<%=curpage+1%>">下一頁</a><%end if%>
<%if rs.pagecount<curpage+1 then%>尾頁<%else%><a href="?curpage=<%=rs.pagecount%>">尾頁</a><%end if%>
</div>

asp數據分頁顯示技術(上下頁版)