可以做个字段 id ,id 是逐渐增加(可能不能是自动的),可以利用id>0 and id<10; 0和10做成变量;
我認為可以用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;
且慢!!! 是这样的。乱费SERVER的开销! 有一个办法可以减少一些开销的 表要有ID,先用(假设每页要20 条记录) select top 20 * from tableName '这样防止ID是中断的 记下LastID(最后的一个ID), 以后的语句全部用select top 20 * from tableName where id>lastID...
你查查你的数据库用什么字段表示记录的序号,比如oracle是ROWID 你可以这样用 select * from (select RowID,name1,name2,namen from table1) where rowid > x and rowid <x+20
<?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" 返回总记录 //就这样吧,太粗糙了,其它的工作你自己完成。?>
用这个试试,我也是从这里知道的,oracle(取20~10)条记录 SELECT * FROM TABLENAME WHERE ROWNUM < 20 MINUS SELECT * FROM TABLENAME WHERE ROWNUM < 10
我是一个新手有一个问题问一下。我刚才试了一下上面的程序。在php4.2.1中mysql_query中不支持top 20吗?我的为什么一加上这个就出现错误提示。 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in
0和10做成变量;
顯示從數據庫中提出的前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;
且慢!!!
是这样的。乱费SERVER的开销!
有一个办法可以减少一些开销的
表要有ID,先用(假设每页要20 条记录)
select top 20 * from tableName '这样防止ID是中断的
记下LastID(最后的一个ID),
以后的语句全部用select top 20 * from tableName where id>lastID...
你可以这样用
select * from (select RowID,name1,name2,namen from table1)
where rowid > x and rowid <x+20
//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" 返回总记录
//就这样吧,太粗糙了,其它的工作你自己完成。?>
SELECT * FROM TABLENAME WHERE ROWNUM < 20
MINUS
SELECT * FROM TABLENAME WHERE ROWNUM < 10
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in
由于我的PHP从不用MSSQL。所在
在访问API你自己查一上。
{
$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>";
}
}