蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

[asp]帮忙看看我的N行M列的分页程序!

主要是不循环读数据,没有分页的效果显示。

<%
dim sql
dim rs
sql="select * from ** 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 "<script>alert('还没有任何电影,要想看的话请联系管理员!')</Script><script Language=Javascript>location.href = '';</script>"
       response.end
   else
          totalPut=rs.recordcount
      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,"list.asp"
            showContent
            showpage totalput,MaxPerPage,"list.asp"
       else
          if (currentPage-1)*MaxPerPage<totalPut then
            rs.move  (currentPage-1)*MaxPerPage
            dim bookmark
            bookmark=rs.bookmark
           showpage totalput,MaxPerPage,"list.asp"
            showContent
            showpage totalput,MaxPerPage,"list.asp"
        else
                currentPage=1
          showpage totalput,MaxPerPage,"list.asp"
           showContent
           showpage1 totalput,MaxPerPage,"list.asp"
              end if
           end if
   end if
   sub showContent


'Split("Sun,Mon,Tue,Wed,Thu,Fri,Sat",",")
        BgImg1 = "06,04,08,09"
        BgImg2 = "12,11,14,15"

       dim i
           i=0
                    %>
                          <%
                                                  i=0
          do while not rs.eof
                  If i mod 3 = 0 Then  MyBgImg = BgImg1 Else MyBgImg = BgImg2
                  MyBgImg = Split(MyBgImg,",")
%>

-------------------------------------------------------------
显示部分
<%
rs.movenext
%>
(N行M列)
-----------------------------------------------------------


<%
             i=i+3
                  if i>=MaxPerPage then exit do
               loop
                              %>

<%
end sub

function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
        n= totalnumber \ maxperpage
else
        n= totalnumber \ maxperpage+1
end if
%>

<table width="450" border="0" align="center" cellspacing="0">
                    <form method=Post action="<%=filename%>?id=<%=id%>&paixu=<%=paixu%>">
                      <tr>
                        <td width="476" height="22">                        <%=id%>&nbsp;&nbsp;共有<font color="#FF9900"><%=totalnumber%></font>部&nbsp;&nbsp;当前:第<font color="#FF9900"><%=CurrentPage%></font>页/共<font color="#FF9900"><%=n%></font>页
                            <%if CurrentPage<2 then%>
                            首页
                            <%else%>
                            <a class=left href="<%=filename%>?id=<%=id%>&paixu=<%=paixu%>&page=1">首页</a>&nbsp; <a class=left href="<%=filename%>?id=<%=id%>&paixu=<%=paixu%>&page=<%=CurrentPage-1%>">上一页</a>                            <%
end if
if n-currentpage<1 then
%>                            <%else%>
                            <a class=left href="<%=filename%>?id=<%=id%>&paixu=<%=paixu%>&page=<%=(CurrentPage+1)%>">下一页</a>&nbsp; <a class=left href="<%=filename%>?id=<%=id%>&paixu=<%=paixu%>&page=<%=n%>">尾页</a>&nbsp;                            <%end if%>
                        <td width="83" align="center"><SCRIPT language=JavaScript>
var chSelect = 'page';
NS_office = NSelect(""
        +"<select name='page' style='width:65px;height:18px;font:12px;color:#B4D1EB;' onchange='javascript:submit()'>"
        <%for i = 1 to n%>
        +"<option value=\"<%=i%>\" <%if cint(CurrentPage)=cint(i) then%> selected <%end if%>>第<%=i%>页</option>"
        <%next%>
        +"</select>", "", "4977B2", "1D3D66", "1px solid #1D3D66", "" );
                          </SCRIPT></td>
                      </tr>
                    </form>
                  </table>
                                  <%
end function
%>
                  <%
sub gotopage
end sub
%>
                                  </td>
  </tr>
</table>





Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com