是否可以限制从 MYSQL 数据库显示的结果?
目前结果显示在 html 表中,我如何只显示最新条目?
<?php
$con = mysql_connect("localhost","cl49-XXX","XXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cl49-XXX", $con)or die("Unable to select database");
$result=mysql_query("SELECT * FROM products") or die('You need enter a category');
echo "<tr>"; // first row beginning
for ($i = 1; $i <= mysql_num_rows($result); $i++)
{
$row = mysql_fetch_array($result);
$prodname = $row['prodname'];
$prodID = $row['prodID'];
$catagory = $row['catagory'];
echo "
<td>$prodID</td>
<td>$prodname</td>
<td>$catagory</td>
<td>
<a href=deleteproduct.php?q=$prodID' class='btn mini red'>
<i class='icon-trash'></i> Delete Item</a>
</td>";
echo "</tr><tr>"; // it's time no move to next row
}
echo "</tr>"; // last row ending
?>