日期:2013-06-23  浏览次数:20880 次

<%
set rs=createobject("adodb.recordset")
rs.open "select * from table",conn,1,1
if rs.eof then
    response.write "No records!"
else
    if not isempty(request("page")) then
        currentPage=cint(request("page"))
    else
        currentPage=1
    end if

    rs.pagesize=10
    totalPut=rs.recordcount  
    totalPage=rs.pagecount
    MaxPerPage=rs.pagesize
    if currentpage<1 then
        currentpage=1
    end if
    if currentpage>totalPage then
        currentpage=totalPage
    end if
    if currentPage=1 then
        showhead  '分页结果显示头,如共有几条几页记录之类的东东
        showContent  '显示该页记录集
        showfoot  '分布结果显示尾,如至其它页面间的链接等
    else
        if (currentPage-1)*MaxPerPage<totalPut then
            rs.move  (currentPage-1)*MaxPerPage
            showhead
            showContent
            showfoot
        else
        end if
    end if
end if

sub showContent
dim i,j
i=1
do while not (rs.eof or err)
%>
     '在此输入单记录显示模式
        <%
    if i>=MaxPerPage then exit do  
    i=i+1
    rs.movenext
loop
end sub  

至其它页面的链接代码:
1、链接到上页、下页、首页和尾页
<%
If currentPage <> 1 Then
    Response.Write "<A HREF=show.asp>[第一页]</A> "
    Response.Write "<A HREF=show.asp?Page=" & (currentPage-1) & ">[上一页]</A> "
End If
If currentPage <> rs.PageCount Then
    Response.Write "<A HREF=show.asp?Page=" & (currentPage+1) & ">[下一页]</A> "
    Response.Write "<A HREF=show.asp?Page=" & totalPage & ">[最后一页]</A> "
End If
%>
2、跳转至其中的任一页面
<form action="show.asp" method="GET" align="right" style="margin-top: 0px; margin-bottom: 0px">
<%for i=1 to n
    response.write "<option value="& i  
    if currentpage=i then  
        response.write " selected"
    end if
    response.write ">"& i &"</option>"
next
response.write "</select>"
response.write "<input class=buttonface type='submit'  value='GO'  style='font-family: 宋体; font-size: 8pt;height:19'>"
%>
3、链接到当前页开始的后十页
<%
for j=currentpage+1 to currentpage+10
   &nb