復制代碼 代碼如下:
<%
set rs=server.createobject("adodb.recordset")
exce="sql" 'sql 查詢語句
rs.open exce,conn,1,1
%>
然後是分頁屬性的設置
<%
rs.PageSize=3 ‘設置頁碼
pagecount=rs.PageCount '獲取總頁碼
page=int(request("page")) '接收頁碼
if page<=0 then page=1 '判斷
if request("page")="" then page=1
rs.AbsolutePage=page '設置本頁頁碼
%>
最後是body裡的分頁顯示
<%
if rs.bof and rs.eof then
response.write("NULL")
else
for i=1 to rs.PageSize
response.write rs("name")
response.write("<hr>")
rs.movenext
next
end if
%>
<p>
<%if page=1 and not page=pagecount then%>
首頁|前一頁
<a href="log1.asp?page=<%=page+1%>">後一頁</a>|
<a href="log1.asp?page=<%=pagecount%>">末頁</a>
<%elseif page<>1 and not page=pagcount then%>
<a href="log1.asp?page=1">首頁</a>|
<a href="log1.asp?page=<%=page-1%>">前一頁</a>|
<a href="log1.asp?page=<%=page+1%>">後一頁</a>|
<a href="log1.asp?page=<%=pagecount%>">末頁</a>
<%elseif page=pagecount then%>
<a href="log1.asp?page=1">首頁</a>|
<a href="log1.asp?page=<%=page-1%>">前一頁</a>|
下一頁|
末頁
<%end if%>