用以上代码实现分页,出现以下错误:
分页功能是引入了,但数据没有循环出来odbc 分页 phpphpodbc分页

解决方案 »

  1.   

    sql server?
    不支持limit语法的吧
      

  2.   

    本帖最后由 xuzuning 于 2013-02-28 16:22:06 编辑
      

  3.   

    通用模板
    $sql = 'select * from tbl_name'; //查询指令
    $page = 1; //出啊如的页号
    $pagesize = 20; //每页记录数
    $start = ($page-1) * $pagesize; //起始偏移
    $sqls =<<< SQL
    SELECT * FROM 
    (
    SELECT A.*, ROWNUM RN 
    FROM ($sql) A 
    WHERE ROWNUM < $start+$pagesize
    )
    WHERE RN >= $start
    SQL;//$sqls 就是待执行 SQL 指令串
      

  4.   


    <?php session_start();?>
    <?php 
                include_once 'global.php';        //包含了分页类
                include_once 'mss_con_a.php';     //新购数据库

    $sql="select f_p_name,f_p_name2,f_p_price1,f_p_price2,f_p_price3,f_p_fl from f_product where f_p_fl<>0 order by f_p_fl desc";        

     $result=odbc_exec($connection,$sql); 
     
           $total= odbc_num_rows($result);
       
       //echo $total;exit();
                        
                        if ($total==0) {
                         echo "暂无数据!";
                         exit();
                        }else{
                         pageft($total,10);                       $sql1 = "select f_p_name,f_p_name2,f_p_price1,f_p_price2,f_p_price3,f_p_fl from f_product where f_p_fl<>0 order by f_p_fl desc limit $firstcount,$displaypg";                  $result1=odbc_exec($connection,$sql1);
      
                        }  
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title><style type="text/css">
    <!--
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    }
    body,td,th {
    font-size: 12px;
    }
    -->
    </style><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="36%" height="45">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D4D0C8">
          <tr>
            <td height="24" colspan="5" bgcolor="#FFC751"><div align="center"><strong>新购商城(www.newgou.cn)Vip会推广返利表</strong></div></td>
          </tr>
          <tr>
            <td width="40%" height="24" bgcolor="#FFDF9D"><strong>产品名称</strong></td>
            <td width="16%" height="24" bgcolor="#FFDF9D"><strong>产品原价</strong></td>
            <td width="16%" bgcolor="#FFDF9D"><strong>商城普通会员价</strong></td>
            <td width="13%" bgcolor="#FFDF9D"><strong>Vip推广价</strong></td>
            <td width="15%" height="24" bgcolor="#FFDF9D"><strong>vip返利值</strong></td>
          </tr>
      <?php 
       
         while ($row=odbc_fetch_array($result1)){
     
      $pname = mb_convert_encoding("$row[f_p_name]", "utf-8", "gbk");
      
      echo "  
          <tr bgcolor=\"#EAE8E3\" onmouseover=\"this.bgColor='#f6f6f6';\" onmouseout=\"this.bgColor='#EAE8E3';\">
            <td height=\"20\"><a href=http://www.newgou.cn/cp-".$row['f_p_name2'].".html target=_blank>$pname</a></td>
            <td>".$row['f_p_price1']."</td>
            <td>".$row['f_p_price2']."</td>
            <td>".$row['f_p_price3']."</td>
            <td>".$row['f_p_fl']."</td>
          </tr>
         ";
              }
      echo "
      <tr><td>".$pagenav."</td></tr>
        </table>
      
      ";
      ?> 

        <br>
        </td>
      </tr>
      </table>
    </body>
    </html>你看看这个怎么改?