CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

一个经典的问题(asp)

楼主venket(创业先锋)2005-04-01 16:49:37 在 Web 开发 / ASP 提问

我想在我的页面中使用分页查询  
  但是我不知道为什么在不分页的时候没有什么问题,但是一分的情况下,第二个页面就出错了  
  我看了论坛上的一些方法  
  但是还是不行.高手们,给点意见啊 问题点数:20、回复次数:14Top

1 楼jinjie0577(风之友)回复于 2005-04-01 16:52:42 得分 0

到底是怎么个出错法,你这样说,叫别人怎么理解啊Top

2 楼venket(创业先锋)回复于 2005-04-01 16:56:08 得分 0

是第二个页面把所有的数据都显示出来了  
  就是说,我们之前的传来的条件没有效了Top

3 楼venket(创业先锋)回复于 2005-04-01 16:58:49 得分 0

代码如下:各位帮帮忙啊  
  就是第二个页面开始,出来的数据,不是我想要查询的数据了  
  <!--#include   file="../CONN.INC"-->  
  <html>  
  <head>  
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">  
  <link   rel="stylesheet"   href="../main/style.css"   type="text/css">  
   
  <style   type="text/css">  
  <!--  
  @media   print{  
  INPUT   {suppComplay:none}  
  }  
  th   {  
  font-size:   14px;  
  color:   #6f6f6f;  
  padding:   5px;  
  }  
  td   {  
  padding:   5px;  
  }  
  .style1   {  
  font-size:   14px;  
  color:   #333333;  
  }  
  .style2   {font-size:   12px}  
  .style3   {color:   #008BCE}  
  .style4   {font-size:   14px}  
  -->  
  </style>  
  </head>  
  <body   bgcolor="#FFFFFF"   topmargin="8">  
  <p><div   align="left">  
      <table   width="90%"     border="0"   cellspacing="0"   cellpadding="0">  
              <tr>  
                  <td><span   class="style1"><br>  
  目前操作栏目   :供应商信息</span></td>  
                  <td>&nbsp;</td>  
              </tr>  
              <tr>  
                  <td><blockquote>  
                      <p><span   class="style2">[</span>   <a   href=suppCompNew.asp><span   class="style1">添加新的供应商信息</span></a>   <span   class="style2">]</span></p>  
                  </blockquote></td>  
                  <td><div   align="right">  
                      <form   name="form1"   method="post"   action="suppComp.asp">  
                          <select   name="flt"   id="flt">  
                          <option   value="">全部</option>  
                          <option   value="where   comp_name   like">供应商</option>  
                          <option   value="where   tel   like">电话</option>  
                          </select>  
                          <input   type="text"   name="sqlFlt">  
                          <input   type="submit"   name="Submit"   value="提交">  
                      </form>  
                  </div></td>  
          </tr>  
      </table>  
          <p><blockquote>  
      <table   width="80%"   border="0"   align="center"   cellpadding="5"   cellspacing="1"   bgcolor="#999999"   id="mxh">  
      <tr   align="center"   bgcolor="#008BCE">    
          <td   colspan="9"><span   class="style4"><font   color="#FFFFFF">供   应   商   管   理   页   面</font></span></td>  
      </tr>  
      <tr   bgcolor="#f5f5f5"   align="center">  
              <th   scope="col"><span   class="style3">供应商</span></th>  
              <th   scope="col"><span   class="style3">地址</span></th>  
              <th   scope="col"><span   class="style3">电话</span></th>  
              <th   scope="col"><span   class="style3">传真号码</span></th>  
              <th   scope="col"><span   class="style3">联系人</span></th>  
              <th   colspan="2"   scope="col"><span   class="style3">功能</span></th>  
  </tr>  
  <%  
        const   MaxPerPage=6  
        dim   totalPut        
        dim   CurrentPage  
        dim   TotalPages  
        dim   i,j  
        dim   idlist  
        dim   name  
  dim   sql  
        dim   rs  
        i=0  
   
  if   not   isempty(request("page"))   then  
              currentPage=cint(request("page"))  
        else  
              currentPage=1  
        end   if  
       
  %>  
  <%  
    if(len(trim(request("flt")))>0)   Then  
  sql="select   *   from   ms_company   "&request("flt")&"'%"&request("sqlFlt")&"%'"  
  else    
  sql="select   *   from   ms_company"  
  end   if  
  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  
                          showContent  
                                  showpage   totalput,MaxPerPage,"suppComp.asp"  
                else  
                      if   (currentPage-1)*MaxPerPage<totalPut   then  
                                  rs.move     (currentPage-1)*MaxPerPage  
                          dim   bookmark  
                          bookmark=rs.bookmark  
                          showContent  
                            showpage   totalput,MaxPerPage,"suppComp.asp"  
                  else  
                  currentPage=1  
                        showContent  
                        showpage   totalput,MaxPerPage,"suppComp1.asp"  
              end   if  
        end   if  
        rs.close  
        end   if  
        set   rs=nothing      
        conn.close  
        set   conn=nothing  
        sub   showContent  
  %>  
  <%do   while   not   rs.eof%>  
      <tr   bgcolor="#FFFFFF">    
          <td><div   align="center"><%=trim(rs("comp_name"))%></div></td>  
          <td><div   align="center"   style="word-Wrap:break-word"><%=trim(rs("comp_addr"))%></div></td>  
  <td   height="20"   align="center"><%=rs("tel")%></td>  
          <td><div   align="center"><%=rs("fax")%></div></td>  
  <td><div   align="center"><%=rs("person")%></div></td>  
          <td   align="center"><a   href="suppCompUpd.asp?compCode=<%=rs("comp_code")%>"><img   src="../images/edit.gif"   width="16"   height="16"   border="0"></a></td>  
          <td   align="center"><img   src="../images/delete.gif"   width="16"   height="16"   border="0"   onclick="f_del('<%=trim(rs("comp_code"))%>')"></a></td>  
      </tr>  
      <%    
  i=i+1  
  if   i>=MaxPerPage   then   exit   do  
  rs.movenext  
  loop  
  %>  
  </table>  
  <br>  
  <table   width="80%"   height="26"   border="0"   align="center"   cellpadding="0"   cellspacing="0">  
    <tr   class="font">    
      <td   align="right"><span   class="style1">  
  <%  
  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  
      response.write   "<p   align='right'>&nbsp;"  
      if   CurrentPage<2   then  
          response.write   "<font   color='#000080'>首页   上一页</font>&nbsp;"  
      else  
          response.write   "<a   href="&filename&"?page=1>首页</a>&nbsp;"  
          response.write   "<a   href="&filename&"?page="&CurrentPage-1&">上一页</a>&nbsp;"  
      end   if  
      if   n-currentpage<1   then  
          response.write   "<font   color='#000080'>下一页   尾页</font>"  
      else  
          response.write   "<a   href="&filename&"?page="&(CurrentPage+1)&">"  
          response.write   "下一页</a>   <a   href="&filename&"?page="&n&">尾页</a>"  
      end   if  
        response.write   "&nbsp;页次:<strong><font   color=red>"&CurrentPage&"</font>/"&n&"</strong>页   "  
        response.write   "&nbsp;共<b><font   color=red>"&totalnumber&"</font></b>条   <b>"&maxperpage&"</b>条/页</font>   "  
                 
  end   function  
  %>  
  <%  
  set   rs=nothing  
  %>  
      </span>  
      </td>  
    </tr>  
  </table>  
  </div>  
  </body>  
  </html>  
  <script   language="javascript">  
            function   f_del(i)  
            {  
        if(confirm("你想要删除吗?"))  
            {  
            window.location="suppCompDel.asp?compCode="+i;  
            }  
            }  
  </script>  
  Top

4 楼jinjie0577(风之友)回复于 2005-04-01 17:04:48 得分 20

问题就是出在你点上一页或下一页时,丢失了搜索的关键字,应该把关键字继续传递下去才会有效  
   
  如:  
  response.write   "<a   href="&filename&"?page=1&keyword="&request("keyword")&">首页</a>&nbsp;"  
          response.write   "<a   href="&filename&"?page="&CurrentPage-1&"&keyword="&request("keyword")&">>上一页</a>&nbsp;"  
   
  其中keyword为关键字的变量名称Top

5 楼lstup(流水)回复于 2005-04-01 17:12:31 得分 0

http://www.37zz.com/ShowPost.asp?id=58  
  看看,会有收获的Top

6 楼poonzsp(怒放的生命)回复于 2005-04-01 17:14:50 得分 0

没有传输参数`Top

7 楼zhanglemail(咕噜)回复于 2005-04-01 17:30:08 得分 0

楼上的都回答了!!!Top

8 楼yifan268(天涯)回复于 2005-04-01 17:33:05 得分 0

当你按下一页的时候,你的一个变量当中的值没有了.  
  所以你要用一个隐含字断继续传递...Top

9 楼QSmile(RedFox)回复于 2005-04-02 11:52:02 得分 0

把   文件定义成两种参数方式  
   
  一种是用   Form   一种是用QueryString   两种同时工作  
   
  QueryString   时如这样   sss.asp?keyword=张三&GroupID=1&page=5Top

10 楼hnzhangyls(守望的狮子)回复于 2005-04-02 11:57:18 得分 0

变量的值传丢啦Top

11 楼daknis(杰瑞)回复于 2005-04-02 13:31:30 得分 0

仔细检查一下Top

12 楼Aspclass(Asp初学者)回复于 2005-04-02 14:04:18 得分 0

你娃娃   哦。。你的filename是什么意思。。。该是一个文件名吧。。  
  如果是你前面又没有定义     你的filename=什么呢??  
  建议你不要这样写可以这样。。  
  做面码都是在本面里面做。如   本页为   1.asp  
  response.write   "<a   href="1.asp?page="&CurrentPage-1&"">上一页</a>&nbsp;"  
  这样写就应该对了  
  Top

13 楼LW1981(旋转的线)回复于 2005-04-02 16:55:25 得分 0

用session把關鍵字一直傳下去Top

14 楼riyao(日尧)回复于 2005-04-02 16:58:27 得分 0

参数没传递。。Top

相关问题

  • 一个积为经典的问题(asp)
  • 哪里有比较经典的ASP电子书下载?急!!!!!!!
  • 一个关于sql在asp中的经典问题
  • 推荐: 一个经典的 asp写的erp系统
  • 大家给我推荐几本asp/asp.net的经典书籍嘛!!!!!!!!!!!!!!!!!!!!!!!
  • [讨论]ASP数据库连接函数(经典)
  • ASP有什么好书?(经典的、讲解清晰透彻、可操作性强)
  • 高分求《asp应用经典》这本书中第11章的源程序!
  • 那里可以下载Asp实务经典(作者林金霖)这本书啊?
  • 入门问题,关于《ASP。NET 1.1 入门经典》第一个示例

关键词

  • asp
  • totalput
  • maxperpage
  • currentpage
  • 供应商
  • then
  • else

得分解答快速导航

  • 帖主:venket
  • jinjie0577

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo