![](/img/trans.png)
[英]How to display mysql data from php in html form.(NOT TABLE)
[英]Showing Mysql table data in html form with php
我正在HTML表格內用php顯示Mysql表格中的數據,但是我還需要2件事才能完成該表格:
1-如何為表行使用4種不同的CSS類來改變顏色,我現在使用class ='success'我想使用3種以上的顏色,每個表行應使用一種顏色,怎么做? 任何簡單的例子,例如循環之類的東西?
2-數據顯示從表中的最舊記錄到最新記錄,我想顯示相反的數據,因此最后一條記錄在html表中顯示為第一。
我對此表的代碼:
<?php echo "<table class='table'>
<thead>
<tr>
<th>Order#</th>
<th>Name</th>
<th>Total</th>
<th>Submitted On</th>
<th>Status</th>
</tr> </thead>";
while($row = mysqli_fetch_array($result))
{
echo "<tr class='success'>";
echo "<td>" . $row['lite_order_id'] . "</td>";
echo "<td>" . $row['lite_item_name'] . "</td>";
echo "<td>" . $row['lite_email'] . "</td>";
echo "<td>" . $row['lite_country'] . "</td>";
echo "<td>" . $row['lite_order_total'] . "</td>";
echo "</tr>"; }
echo "</table>"; ?>
要獲取反向記錄,可以使用mysql ORDER BY子句或PHP函數array_reverse()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.