我使用PHP從MySQL數據庫中提取表。在PHP中顯示來自MySQL的結果旁邊的圖像?
這大致是我使用的代碼,顯然我有更多的列,但這是代碼的演示版本。
如您所見,代碼按銷售名稱排序。現在我想要做的是,根據銷售計數在前十名賣家旁邊顯示一個小圖標。 因此,如果銷售計數是前十位數字之一,則必須在名稱旁顯示一個小圖片。
可以這樣做嗎?
<?php
// Get all the data from the "sales" table
$result = mysql_query("SELECT * FROM sales ORDER BY SalesName") or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Sales Name</th> <th>Sales Count</th> </tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['SalesName'];
echo "</td><td>";
echo $row['SalesCount'];
echo "</td></tr>";
}
echo "</table>";
?>