可以做个字段 id ,id 是逐渐增加(可能不能是自动的),可以利用id>0 and id<10;
0和10做成变量;

解决方案 »

  1.   

    可以做个字段 id ,id 是逐渐增加(可能不能是自动的),可以利用id>0 and id<10;
    0和10做成变量;
      

  2.   

    我認為可以用mysql_data_seek()這個函數﹐寫一段代碼﹐
    顯示從數據庫中提出的前15條記錄﹐你看看吧﹐改一下就可以實現分頁。
    $rows=mysql_num_rows($result)
    @mysql_data_seek($result,$rows-15);
    if($row<15)$l=$rows;else$l=15;
    for ($i=1;$i<=$l;$i++){
    list($time)=mysql_fetch_row($result);
    echo $time;
      

  3.   


    且慢!!!
    是这样的。乱费SERVER的开销!
    有一个办法可以减少一些开销的
    表要有ID,先用(假设每页要20 条记录)
         select top 20 * from tableName  '这样防止ID是中断的
         记下LastID(最后的一个ID),
       以后的语句全部用select top 20 * from tableName where id>lastID...
      

  4.   

    你查查你的数据库用什么字段表示记录的序号,比如oracle是ROWID
    你可以这样用
    select * from (select RowID,name1,name2,namen from table1)
    where rowid > x and rowid <x+20
      

  5.   

    哈哈,这个问题我当初就非常烦,你看看SQL server关于建立游标的说明吧,每次调用数据库时就建立游标,我的论坛分页就是这样做的,把你的邮箱给我,我把代码给你。我的论坛 http://ynwa.yeah.net
      

  6.   

    <?php
    //mytest.php
    mysql_connect();
    $result=mysql_db_query("dbname","select top 20 id,f1,f2,f3 from tablename where id>".$lastid);
    while($row=mysql_fetch_row($result))
    {
       echp $row[0]."<br>";
       $lastID=$row[0];
       $count++;
    }
    if($count==20)
       echo "<a href='mytest.php?lastid=$lastID'>next</a>";
    esle
       echo "<a href='mytest.php?lastid=$lastID'>pre</a>";
    //if you want to get page count
    //user "select count(*) form table" 返回总记录
    //就这样吧,太粗糙了,其它的工作你自己完成。?>
      

  7.   

    用这个试试,我也是从这里知道的,oracle(取20~10)条记录
    SELECT * FROM TABLENAME WHERE ROWNUM < 20 
    MINUS 
    SELECT * FROM TABLENAME WHERE ROWNUM < 10
      

  8.   

    我是一个新手有一个问题问一下。我刚才试了一下上面的程序。在php4.2.1中mysql_query中不支持top 20吗?我的为什么一加上这个就出现错误提示。
    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in
      

  9.   

    哈,你换成(相关的API)MSSQL吧
    由于我的PHP从不用MSSQL。所在
    在访问API你自己查一上。
      

  10.   

    如果是MYSQL的分页就不会用到上面这么麻烦的语句了。
      

  11.   

    function showPubItem($ShowType,$connectid,$showNum,$BargainModeName,$Pagenum,$recordnum)
    {
       $startrecord=($Pagenum-1)*$recordnum;
       $endrecord=($Pagenum)*$recordnum;
       $MaxNum = $showNum;
       $ScorllItemText="SELECT * FROM (select tmp.*,rownum n from (SELECT FRESOURCENUMBER,fBargainModeName, FRESOURCENAME, FBASEPRICE, ".
       " FBASEPRICEMONEYMARK, FREMISEPERCENT, FVOCATION,TO_CHAR(fBeginDate,'YYYY-mm-dd') FBEGINTIME, ".
       "FAREA  ".
       " FROM VREMISEPROJECT_MEMBER ".
       " where fBargainModeName = '$BargainModeName' Order by FRESOURCENUMBER) tmp) ".
       "  where n>$startrecord and n<=$endrecord ".
       "  ";
       $ResultItem=dbQuery($connectid,$ScorllItemText);
       if($ShowType>=2)
       {
         echo "<p>";
       }
       $MaxNum=$showNum;
       while(dbgetonerow($ResultItem)&& $Num<=$MaxNum)
       {
         $FRESOURCENUMBER=dbresult($ResultItem,"FRESOURCENUMBER");
         $fBargainModeName=dbresult($ResultItem,"FBARGAINMODENAME");
         $FRESOURCENAME=dbresult($ResultItem,"FRESOURCENAME");
         $FVOCATION=dbresult($ResultItem,"FVOCATION");
         $FVOCATION=substr($FVOCATION,0,strpos($FVOCATION,'/'));
         $FBASEPRICE=number_format(dbresult($ResultItem,"FBASEPRICE")/10000,2)."万";
         $FBARGAINSTYLE=dbresult($ResultItem,"FBARGAINSTYLE");
         $FENDTIME=dbresult($ResultItem,"FENDTIME");
         $FBEGINTIME=dbresult($ResultItem,"FBEGINTIME");
         $Num =dbresult($ResultItem,"N");
         if($showNum==0)
         {
         $MaxNum=$Num;
         }
         $FRESOURCENUMBER=chop($FRESOURCENUMBER);     if($ShowType==1)
         {
         //显示类型1表示列表
           echo "<li><A target=_blank href='../code/ItemPubGuide.php?ItemNo=$FRESOURCENUMBER&ItemType=1&BargainMode=$fBargainModeName'  target='_blank'>$FRESOURCENAME</A>";
           echo "<font color='#006600'>[$FBEGINTIME]</font>";
           echo "</li>";
         }
         if($ShowType==2 )
         {
           //显示类型2表示表格
           echo "<img src='../image/huangdian.gif' width='11' height='11'>";
           echo "<a target=_blank href='../code/ItemPubGuide.php?ItemNo=$FRESOURCENUMBER&ItemType=1&BargainMode=$fBargainModeName'  target='_blank'>$FRESOURCENAME</a>";
           echo "<font color='#006600'>[$FBEGINTIME]</font>";
           echo "<br>";
         }
         if($ShowType==3 )
         {
           //显示类型2表示表格
           echo "<font color='#FF0000'>□</font><font color='#879eda'> </font>";
           echo "<a target=_blank href='../code/ItemPubGuide.php?ItemNo=$FRESOURCENUMBER&ItemType=1&BargainMode=$fBargainModeName'  target='_blank'>$FRESOURCENAME</a>";
           echo "<font color='#006600'>[$FBEGINTIME]</font>";
           echo "<br>";
         }
         if($ShowType==4 )
         {
           //显示类型2表示表格
            echo "<img src='../image/huangdian.gif' width=11 height=11>";
            echo " <a target=_blank href='../code/ItemPubGuide.php?ItemNo=$FRESOURCENUMBER&ItemType=1&BargainMode=$fBargainModeName'>$FRESOURCENAME".GetPoint(53,$FRESOURCENAME);
            echo "[$FBEGINTIME]<br>";
            echo " <br>";
            echo "  </a>";
         }
         if($ShowType==5 )
         {
           //显示类型2表示表格
            echo "<font color='#FF0000'>□</font><font color='#879eda'> </font>";
            echo " <a target=_blank href='../code/ItemPubGuide.php?ItemNo=$FRESOURCENUMBER&ItemType=1&BargainMode=$fBargainModeName'>$FRESOURCENAME".GetPoint(53,$FRESOURCENAME);
            echo "[$FBEGINTIME]<br>";
            echo " <br>";
            echo "  </a>";
         }
       }
       if( $ShowType>=2 )
       {
         echo "</p>";
       }
    }