注册 登录
编程论坛 ASP技术论坛

哪位大哥能帮我这个菜鸟解释一下这个THANKS

huye1985 发布于 2008-03-12 10:40, 870 次点击
<%
              SQL="Select * from product where pro_name='product'"
              Set rs=Server.CreateObject("ADODB.RecordSet")
            rs.Open SQL,con,1,1
            rs.PageSize=12
            count=1
            if Request("count")<>"" then
            count=Cint(Request("count"))
                if count<1 then
                    count=1
                end if
                if count>rs.PageCount then
                    count=rs.PageCount
                end if
            end if
            if not rs.Bof and not rs.Eof then
                  rs.ABSolutePage=count
              end if
            pagecountx=rs.pagecount
            for i=0 to 2
                if i*4>=rs.RecordCount-((count-1)*rs.PageSize) then
                    exit for
                end if    
          %>
3 回复
#2
yms1232008-03-12 15:22
<%
              '构造SQL语句查询字符串
              'product可能是商品表
              'pro_name商品名称=product的所有数据
              '意思是查询商品表商品名称为product的所有数据
              SQL="Select * from product where pro_name='product'"
              Set rs=Server.CreateObject("ADODB.RecordSet")
              '建立记录集对象用来执行SQL语句取出数据
            rs.Open SQL,con,1,1
            '执行SQL语句并取出数据到记录集对象rs
            rs.PageSize=12
            '设置当前记录集数据分页显示,每页显示12条数据
            count=1
            '初始化count变量值为1
            '(这样写法个人不推荐,虽然执行没有错误,但是没有声明变量count
            '判断从上一个页面或URL地址传来的参数count是否为空
            if Request("count")<>"" then
            count=Cint(Request("count"))'将文本数据强制转换为数字整数数据
               '如果传来的count大于1则再次初始化count为1
               if count<1 then
                    count=1
                end if
                '如果count大于记录集数据分页的总页数
                if count>rs.PageCount then
                    count=rs.PageCount'将总页数给count变量
                end if
            end if
            '如果记录集有数据
            if not rs.Bof and not rs.Eof then
                  rs.ABSolutePage=count'将count变量传递给记录集的当前页属性,将记录集当前页只向count所在的页
              end if
            pagecountx=rs.pagecount'将总页数给变量pagecountx
            '循环2次
            for i=0 to 2
                '如果i乘以4大于等于总页数减coung-1乘以每页记录数
                if i*4>=rs.RecordCount-((count-1)*rs.PageSize) then
                    exit for'退出循环
                end if
                '这个if判断是一个算法,作什么用的还得看具体程序来分析   
          %>
#3
execoo2008-03-12 15:48
楼上的说的很详细啊。赞一个~~
建议LZ先多看看书,了解下先
#4
huye19852008-03-14 10:00
回复 2# 的帖子
太感谢版主了
1