看板 PHP 關於我們 聯絡資訊
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