作者s890510 (水色星晨)
看板PHP
標題[請益] 有沒有辦法限制他的顯示數目?
時間Mon Apr 2 21:14:38 2007
include "config.php";// 取得系統組態連結資料庫
$sql ="select ID, time, name from news where assign=2 Order By ID Desc";//定
義sql變數的內容
$rs_f = mysql_db_query($dbname, $sql, $link);//送出MySQL查詢
// 資料區域
while ( $row = mysql_fetch_array($rs_f)) {
?><font color="#000000" style="font-size: 8pt"><? echo $row["time"]
?></font>
<a href = "news.php?num=<? echo $row["ID"];?>" target="_blank"><font
color="#000000" style="font-size: 10pt"><? echo
$row["name"];?></font></a><br /><hr />
上面是我的程式原碼,
我想要只顯示出5筆資料就好,
我原本是想要在while後面加一個for迴圈但是會出問題,
有大大可以說要怎用嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.121.213.45
推 litthe:sql裡面加 limit 5 ,或者用if迴圈 推薦前者啦 04/02 21:15
→ s890510:恩,試試看 04/02 21:40