我有一个显示为列表格式的提交表单,我想知道我能做些什么来使列表只显示一定数量的最新提交信息.我正在测试它,目前列表在一个页面上,只显示50多个提交页面很长时间.
<?php
$query='select * from article order by `article`.`time` DESC';
$result=mysql_query($query);
echo '<table width="600px">';
while($row = mysql_fetch_array($result))
{
echo "<td><a href='".$row['url']."'>".$row['title']."</a></td> <td>".$row['description']."</td><td>".$row['type']."</td></tr>";
}
echo '<table>';
?>
Run Code Online (Sandbox Code Playgroud)
欢迎来到SO!修改您的sql语句,如下所示:
$query='SELECT * FROM article ORDER BY `article`.`time` DESC LIMIT 10';
Run Code Online (Sandbox Code Playgroud)
将10更改为应显示的条目数量.