分类分类
关注+2010-02-05作者:
告诉大家一个不错的翻页效果代码:
注:文件名应为index.asp
显示效果如下:
共 100 条,当前第 8/11 页 上一翻页 页首 上一页 [6] [7] [8] [9] [10] 下一页 页尾 下一翻页
<!--#include file=conn.asp --> <%PageShowSize = 5 ’每页显示多少个页 MyPageSize =10 ’每页显示多少条文章 If Not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Or Request("page") <=0 Then MyPage=1 Else MyPage=Int(Abs(Request("page"))) End if set rs=server.CreateObject("ADODB.RecordSet") rs.Source="select * from News order by NewsID desc" rs.Open rs.Source,conn,3,1 If Not rs.eof then rs.PageSize = MyPageSize MaxPages = rs.PageCount rs.absolutepage = MyPage total = rs.RecordCount %><body link="#000000" vlink="#000000" alink="#000000"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000" style="border-collapse: collapse"> <% for i=1 to rs.PageSize if not rs.EOF then %> <tr bgcolor="#FFFFFF"> <td width="63%" height="30" ><%=trim(rs("title"))%></td> <% rs.MoveNext end if next %> </tr></table> <table> <tr> <td colspan=2 align=center height=30>共 <%=total%> 条,当前第 <%=Mypage%>/<%=Maxpages%> 页 <% url="index.asp?" PageNextSize=int((MyPage-1)/PageShowSize)+1 Pagetpage=int((total-1)/rs.PageSize)+1 if PageNextSize >1 then PagePrev=PageShowSize*(PageNextSize-1) Response.write "<a class=black href=’" & Url & "page=" & PagePrev & "’ title=’上" & PageShowSize & "页’>上一翻页</a> " Response.write "<a class=black href=’" & Url & "page=1’ title=’第1页’>页首</a> " end if if MyPage-1 > 0 then Prev_Page = MyPage - 1 Response.write "<a class=black href=’" & Url & "page=" & Prev_Page & "’ title=’第" & Prev_Page & "页’>上一页</a> " end if if Maxpages>=PageNextSize*PageShowSize then PageSizeShow = PageShowSize Else PageSizeShow = Maxpages-PageShowSize*(PageNextSize-1) End if If PageSizeShow < 1 Then PageSizeShow = 1 for PageCounterSize=1 to PageSizeShow PageLink = (PageCounterSize+PageNextSize*PageShowSize)-PageShowSize if PageLink <> MyPage Then Response.write "<a class=black href=’" & Url & "page=" & PageLink & "’>[" & PageLink & "]</a> " else Response.Write "<B>["& PageLink &"]</B> " end if If PageLink = MaxPages Then Exit for Next |
if Mypage+1 <=Pagetpage then Next_Page = MyPage + 1 Response.write "<a class=black href=’" & Url & "page=" & Next_Page & "’ title=’第" & Next_Page & "页’>下一页</A>" end if if MaxPages > PageShowSize*PageNextSize then PageNext = PageShowSize * PageNextSize + 1 Response.write " <A class=black href=’" & Url & "page=" & Pagetpage & "’ title=’第"& Pagetpage &"页’>页尾</A>" Response.write " <a class=black href=’" & Url & "page=" & PageNext & "’ title=’下" & PageShowSize & "页’>下一翻页</a>" End if %> </td> </tr> </table> <br> <% else %> <br> <table width="97%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000" > <tr> <td height="35" colspan=2 align="center" bgcolor="#abb8d6" > <p><b>没有信息!</b></p> </td> </tr> </table> <% End If %> <% rs.close set rs=nothing conn.close set conn=nothing %> |
相关文章
更多+相同厂商
热门推荐
点击查看更多
点击查看更多
点击查看更多
说两句网友评论