| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1166 人关注过本帖
标题:翻页问题,急啊。
只看楼主 加入收藏
虫子8
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-9
收藏
 问题点数:0 回复次数:10 
翻页问题,急啊。
可以翻页,但是下一页的内容和第一页的是一样的。哪位高手可以帮我,非常急啊。


代码如下,哪位朋友帮我分析一下,谢谢。

   <%
     Dim class2,class3,id,prm1,prm2,maxnum,max,link
     id=int(request("id"))
     page=int(request.QueryString("page"))
              If page=0 Then
                 page=1
              End If
              set cmd=Server.CreateObject(")
              cmd.ActiveConnection=conn
              
              
     set class4num=cmd.CreateParameter("@class4",3,1)
              cmd.Parameters.Append class4num
     cmd("@class4")=id
     set pagenum=cmd.CreateParameter("@pagenum",3,1)
              cmd.Parameters.Append pagenum
              cmd("@pagenum")=page
     set maxnum=cmd.CreateParameter("@maxnum",3,2)
     cmd.Parameters.Append maxnum
     cmd.execute()
     max=cmd("@maxnum")
     cmd.Prepared=true
     Set rs=cmd.execute
     rs.AbsolutePage=page
     If (rs.Bof and rs.Eof) Then
        response.Write("<br><br><center><span class='css'>很抱歉,没有找到符合您查询条件的商户……</span></center>")
     Else
   %>
            <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0" class="css">
              <tr>
                <td width="4%" height="25"><img src="../images/list.gif" width="15" height="15"></td>
                <td width="96%" valign="bottom"><%=rs("class4name")%> <font color="#FF0000">(<%=max%>)</font></td>
              </tr>
            </table>
   <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0" class="p9">
              <tr>
                <td colspan="4" bgcolor="65CA00"><img src="../../images/block.gif" width="1" height="2"></td>
              </tr>
              <tr>
                <td width="214" height="25" align="left" bgcolor="E8F6D9">商户名称</td>
                <td width="95" align="left" bgcolor="E8F6D9">折扣</td>
                <td width="208" align="left" bgcolor="E8F6D9">地址</td>
                <td width="50" align="center" bgcolor="E8F6D9">详情</td>
              </tr>
              <tr>
                <td colspan="4" bgcolor="65CA00"><img src="../../images/block.gif" width="1" height="1"></td>
              </tr>
            </table>
   <%
     Do While Not rs.Eof
     If rs("istb")=True Then
     link=""&rs("url")&""
     Else
     link="cust.asp?id="&rs("id")&""
     End If
   %>
            <TABLE width="92%" border=0 align=center cellPadding=0 cellSpacing=0 class="css">
              <TR>
                <TD width="216" height=20 align="left"><a href=<%=link%> target="_blank"><%=left(rs("name"),11)%></A></TD>
                <TD width="95" align="left"><a href=<%=link%> target="_blank"><%=left(rs("actor"),11)%></A></TD>
                <TD width="206" align="left"><a href=<%=link%> target="_blank"><%=left(rs("add1"),11)%></A></TD>
                <TD width="50" align=center><a href=<%=link%> target="_blank">查看</A></TD>
              </TR>
              <tr>
                <td colspan="4" background="../images/dot_02.gif"><img src="../images/block.gif" width="1" height="1"></td>
              </tr>
            </table>
   <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td bgcolor="65CA00"><img src="../../images/block.gif" width="1" height="1"></td>
              </tr>
            </table>
   <%
     rs.movenext
     Loop
   %>
            <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0" class="p9">
              <tr>
                <td height="25" align="center" bgcolor="E8F6D9">
               <%
      totalnum=int((max-1)/10)
      if totalnum<0 Then
            totalnum=0
      End If
      totalnum=totalnum+1
      If totalnum<=1 Then
         response.Write "上一页<img src='../../images/consume/mark_prev_ten.gif' width='13' height='11'>    "
      response.Write "1 | 2| 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10"
      response.Write "    <img src='../../images/consume/mark_next_ten.gif' width='13' height='11'>下一页"
      Else
         response.Write "上一页<img src='../../images/consume/mark_prev_ten.gif' width='13' height='11'>    "
               If page>=10 then
               response.write"<a href=consumelist.asp?id="&request.QueryString("id")&"&page="&(((cstr(page)\10)-1)*10)+1&">上十页<img src='../../images/consume/mark_prev_ten.gif' width='13' height='11'>    </a> "
               End if
               q=(cstr(page)-1)\10
               If q<0 then
               q=1
               End if
               p=(q*10)+1
               Do while p<((q*10)+11)
            If p=page Then
            If page<totalnum then                       
                  Response.Write p&"|&nbsp"
                        Else
                  Response.Write p&"&nbsp"
         End if
               Elseif p<totalnum then
               Response.Write "<a href=consumelist.asp?id="&request.QueryString("id")&"&page="&p&">"&p&"</a>|&nbsp"
               Elseif p=totalnum then
               Response.Write "<a href=consumelist.asp?id="&request.QueryString("id")&"&page="&p&">"&p&"</a>&nbsp"
               End If
               p=p+1
               Loop
      response.Write "    <img src='../../images/consume/mark_next_ten.gif' width='13' height='11'>下一页"
               A=totalnum
               If (A mod 10)=0 then
               A=totalnum-1
               End if
               If page<(A\10)*10 then
               response.write"<a href=consumelist.asp?id="&request.QueryString("id")&"&page="&((((cstr(page)-1)\10)+1)*10)+1&">    <img src='../../images/consume/mark_next_ten.gif' width='13' height='11'>下十页</a>"
               End if
      End If
              %>
                </td>
              </tr>
            </table>
            <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td bgcolor="65CA00"><img src="../../images/block.gif" width="1" height="2"></td>
              </tr>
            </table>
   <%
     End If
     call closeall()
   %>
          </td>
        </tr>
      </table>
    </td>
    <td width="1" bgcolor="#CCCCCC"><img src="../images/block.gif" width="1" height="1"></td>
  </tr>
</table>
搜索更多相关主题的帖子: cmd page int request 
2005-06-09 16:59
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
收藏
得分:0 
好长呀,,大哥...

面朝大海,春暖花开!
2005-06-09 17:02
Grt
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-6-1
收藏
得分:0 
我也碰到过相同的问题,解决的方法是在page=int(request.QueryString("page"))这一句下加一段代码使记录集向后跳 当然这不是最正确的方法 但应该可以解决问题
for i=1 to (page-1)*rs.pagesize then
rs.movenext
next
2005-06-09 18:35
虫子8
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-9
收藏
得分:0 
GRT大哥,加进去后,显示 错误类型: Microsoft VBScript 编译器错误 (0x800A0401) 语句未结束 /consume/html/consumelist.asp, line 87, column 32 for i=1 to (page-1)*rs.pagesize then -------------------------------^ 要怎么改啊, 有哪位朋友可以帮我吗。
2005-06-10 15:10
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
收藏
得分:0 
<!-- #include file="conn.asp" -->
<%
set rs=server.CreateObject("adodb.recordset")
sql="select  * from chenggong   order by newsid desc"
rs.open sql,conn,3,3
  %>
<%
count=10
d=request("id")
if d="" then
page=1
n=1
else
page=d
n=count*(d-1)
end if
%>
<% yushu=rs.recordcount mod count
if yushu=0 then
totalpage=rs.recordcount/count
else
totalpage=int(rs.recordcount/count)+1
end if
k=0
if d="" then
do while not rs.eof%>
                <%k=k+1%><Br>
   <table width="95%"   border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
        <tr bgcolor="#FFFFFF">
         
          <td width="68%"><a href="anlidetail.asp?id=<%= rs("newsid") %>"><%=rs("newsname")%></a>         <div align="center"></div></td>
          <td width="26%"><%=rs("adddate")%></td>
        </tr>
      
      </table>
   
   <%
if k=count then
exit do
end if
rs.movenext
loop
else
for i=1 to n
rs.movenext
next
do while not rs.eof%>
<%k=k+1%>
   <table width="95%"   border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
        <tr>
         
          <td width="68%" bgcolor="#FFFFFF"><a href="anlidetail.asp?id=<%= rs("newsid") %>"><%=rs("newsname")%></a></td>
          <td width="26%" bgcolor="#FFFFFF"><%=rs("adddate")%></td>
        </tr>
      
      </table>
                      
   
<%
if k=count then
exit do
end if
rs.movenext
loop
end if
%>
     <br>
     <table width="500" height="21" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
      <tr>
        <td width="211" align="center">
            
        <% if page>1 then %>
            <a href='news.asp?id=<%=(page-1)%>'><<上一页</a>  
            <%end if%>
            <% if int(page) < int(totalpage) then %>
            <a href='news.asp?id=<%=(page+1)%>'>下一页>></a>
            
            <% end if %>
        </td>
             <td width="124"> 【共<font color=red><%=totalpage%></font>页【第<font color=red><%=page%></font>页】</td>
             <td width="180"> <p align="center">请选择页数:(<font color=red><% for i=1 to totalpage %><a href='news.asp?id=<%=i%>'><%=i%>,<%next%></a></font>)</td>
         
      </tr>
  </table>
 
<%
rs.close
set rs=nothing
conn.close
set conn=nothing%>

面朝大海,春暖花开!
2005-06-10 15:33
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
收藏
得分:0 
自己改一下吧,,

面朝大海,春暖花开!
2005-06-10 15:34
longyu
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2005-6-6
收藏
得分:0 
晕死了!很长呀!

2005-06-10 18:00
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
收藏
得分:0 
大哥你给个短的吧

面朝大海,春暖花开!
2005-06-10 18:43
Grt
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-6-1
收藏
得分:0 
应该是page为空 导致的错误 尝试加在
           If page=0 Then
                 page=1
              End If
的后面 还有这是rs纪录集还未打开 应该再往后放 放在数据集打开之后

[此贴子已经被作者于2005-6-10 19:21:43编辑过]


2005-06-10 19:19
tianlang425
Rank: 1
等 级:新手上路
帖 子:99
专家分:0
注 册:2005-6-13
收藏
得分:0 
看晕了!

偶是新来的!~

     菜鸟飞过!是中国人的就要抵制日货!
2005-06-13 10:17
快速回复:翻页问题,急啊。
数据加载中...
 
   



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

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