标题:ASP初学者:困扰今天的代码看不懂/那个高手帮我解释下
只看楼主
kivenonly
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2009-11-10
 问题点数:0 回复次数:5 
ASP初学者:困扰今天的代码看不懂/那个高手帮我解释下
Sub View_Words()
         dim gbcount,y,j,k
         set rs = conn.execute("select COUNT(*) as gbcount From words")
         gbcount=rs("gbcount")
         rs.close
         
         if gbcount/n = int(gbcount/n) then '计算出分页数
         y=int(gbcount/n)
         else
         y=int(gbcount/n)+1
         end if

         page2= int(page/x)
         if page/x>page2 then page2=page2+1
         k=page2*x
         if k>y then k=y

         '打开留言字段'
         if page=1 then
         sql="select top "&n&" id,name,sex,head,web,email,title,words,date,reply,ip,come,view,qq From words Order By id Desc"
         else
         sql="select id,name,sex,head,web,email,title,words,date,reply,ip,come,view,qq From words Order By id Desc"
         end if
         if Page >100 then
            rs.Open sql,Conn,1
         else
            Set Rs=Conn.Execute(sql)
         end if
         if Page>1 then RS.Move n*page-n
        %>
<table width="700" border="0" cellspacing="1" cellpadding="4" align="center">
          <tr>
            <td width="667" height="20" align="right" class="unnamed1">有<%=gbcount %>条留言  <%=page %>/<%=y %>页 分页
                <a href="?page=1"><<</a>
                <% if page2>1 then %>
                <a href="<%=indexfilename%>?page=<%=page2*x-x%>"><</a>
                <% end if %>
                <% For m =page2*x-(x-1) To k %>
      [<a href="<%=indexfilename%>?page=<%=m%>"><%=m%></a>]
      <%
    Next
    %>
      <% if page2*x < y then %>
      <a href="<%=indexfilename%>?page=<%=m%>">></a>
      <% end if %>
      <a href="?page=<%=y %>">>></a>
            </td>
          </tr>
搜索更多相关主题的帖子: 代码 ASP 困扰 
2009-11-10 22:32
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 

Sub View_Words() '过程定义
         dim gbcount,y,j,k'变量定义
         set rs = conn.execute("select COUNT(*) as gbcount From words")'统计words标的记录数
         gbcount=rs("gbcount")'获得总记录数
         rs.close
         
         '一种分页算法
         if gbcount/n = int(gbcount/n) then '计算出分页数
         y=int(gbcount/n)
         else
         y=int(gbcount/n)+1
         end if

         page2= int(page/x)
         if page/x>page2 then page2=page2+1
         k=page2*x
         if k>y then k=y

         '打开留言字段'
         if page=1 then
         sql="select top "&n&" id,name,sex,head,web,email,title,words,date,reply,ip,come,view,qq From words Order By id Desc"
         else
         sql="select id,name,sex,head,web,email,title,words,date,reply,ip,come,view,qq From words Order By id Desc"
         end if
         if Page >100 then
            rs.Open sql,Conn,1
         else
            Set Rs=Conn.Execute(sql)
         end if
         if Page>1 then RS.Move n*page-n
        %>
<table width="700" border="0" cellspacing="1" cellpadding="4" align="center">
          <tr>
            <td width="667" height="20" align="right" class="unnamed1">有<%=gbcount %>条留言  <%=page %>/<%=y %>页 分页
                <a href="?page=1"><<</a>
                <% if page2>1 then %>
                <a href="<%=indexfilename%>?page=<%=page2*x-x%>"><</a>
                <% end if %>
                <% For m =page2*x-(x-1) To k %>
      [<a href="<%=indexfilename%>?page=<%=m%>"><%=m%></a>]
      <%
    Next
    %>
      <% if page2*x < y then %>
      <a href="<%=indexfilename%>?page=<%=m%>">></a>
      <% end if %>
      <a href="?page=<%=y %>">>></a>
            </td>
          </tr>
总的来说这段就是一段分页代码,但是在ASP里分页不用自己写算法的,这种写法很麻烦。
2009-11-15 18:06
chenguoxing517
Rank: 7Rank: 7Rank: 7
来 自:广东广州
等 级:黑侠
威 望:1
帖 子:154
专家分:619
注 册:2009-9-28
得分:0 
就是分页的代码
2009-11-15 23:58
kivenonly
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2009-11-10
得分:0 
呵呵,谢谢各位大侠,就是自己对这个算法吸收不了
2009-11-17 17:35
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
得分:0 
读书百遍,其意自现,第一次不行,可以二次!

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2009-11-18 22:02
makelee
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2009-11-19
得分:0 
是啊
2009-11-19 13:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-291854-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.370470 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved