正文

通用分页2006-02-25 10:19:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/bakers/10476.html

分享到:

我跟个通用分页 :) 大家修改一点都可以用. 简单修改可以用了。<%'SQL语句自己设置sql="select * from table order by id desc"    Set rs= Server.CreateObject("ADODB.Recordset")    rs.open sql,conn,1,1      if rs.eof and rs.bof then               response.write "<p align='center'> 还 没 有 任 何 文 章 </p>"       else              totalPut=rs.recordcount              if currentpage<1 then                  currentpage=1              end if              if (currentpage-1)*MaxPerPage>totalput then               if (totalPut mod MaxPerPage)=0 then                     currentpage= totalPut \ MaxPerPage              else                      currentpage= totalPut \ MaxPerPage + 1               end if              end if               if currentPage=1 then                   showpage totalput,MaxPerPage,"manage.asp"                    showContent                    showpage totalput,MaxPerPage,"manage.asp"               else                  if (currentPage-1)*MaxPerPage<totalPut then                        rs.move  (currentPage-1)*MaxPerPage                       showpage totalput,MaxPerPage,"manage.asp"'文件名字简单修改                        showContent                         showpage totalput,MaxPerPage,"manage.asp"                else                    currentPage=1                       showpage totalput,MaxPerPage,"manage.asp"                       showContent                       showpage totalput,MaxPerPage,"manage.asp"                  end if           end if       rs.close       end if                   set rs=nothing         conn.close       set conn=nothing%><%'下面是显示内容部分       sub showContent           dim i       i=0%><!--你的内容显示部分--><%    i=i+1          if i>=MaxPerPage then exit do          rs.movenext    loopend sub%><%'页码function showpage(totalnumber,maxperpage,filename)  dim n  if totalnumber mod maxperpage=0 then     n= totalnumber \ maxperpage  else     n= totalnumber \ maxperpage+1  end if  response.write "<p align='center'>&nbsp;"  if CurrentPage<2 then    response.write "<font color='#000080'>首页 上一页</font>&nbsp;"  else    response.write "<a href="&filename&"?page=1&txtitle="&title&">首页</a>&nbsp;"    response.write "<a href="&filename&"?page="&CurrentPage-1&"&txtitle="&title&">上一页</a>&nbsp;"  end if  if n-currentpage<1 then    response.write "<font color='#000080'>下一页 尾页</font>"  else    response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&txtitle="&title&">"    response.write "下一页</a> <a href="&filename&"?page="&n&"&txtitle="&title&">尾页</a>"  end if   response.write "<font color='#000080'>&nbsp;页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "    response.write "<font color='#000080'>&nbsp;共<b>"&totalnumber&"</b>个文档 <b>"&maxperpage&"</b>个文档/页</font> "       end function%>http://www.programfan.com/club/

阅读(3024) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册