如何根據數據庫中的數據顯示數量。
例如,上面的圖片顯示了數據庫中的數據摘錄。在我的數據庫中有兩個數據。因此,我想在No欄中顯示編號1和2。
如果數據庫中有四個數據,我想在No列顯示數字1,2,3和4。
編碼來顯示上述表
<?php
$sql= mysql_query ("SELECT * FROM employee INNER JOIN cash ON employee.emp_id = cash.emp_id WHERE cash_status='Pending'");
echo "<table id='dataTable' width='850' border='1' align='center'>";
echo "<tr>
<th height='50'>No</th>
<th height='50'>Employee Number</th>
<th height='50'>Name</th>
<th height='50'>Department</th>
<th height='50'>Date Apply</th>
<th height='50'>Date Cash To Be Use</th>
<th height='50'>Amount</th>
<th height='50'>Status</th>
<th height='50'>Cash Id</th>
<th height='50'>View</th>
</tr>";
while ($row = mysql_fetch_array($sql))
{
echo "<tr>";
echo "<td align='center' height='30'></td>";
echo "<td align='center' height='30'>" .$row['emp_id']. "</td>";
echo "<td align='center' height='30'>" .$row['emp_name']. "</td>";
echo "<td align='center' height='30'>" .$row['emp_department']. "</td>";
echo "<td align='center' height='30'>" .$row['cash_dapply']. "</td>";
echo "<td align='center' height='30'>" .$row['cash_duse']. "</td>";
echo "<td align='center' height='30'>RM" .$row['cash_amount']. "</td>";
echo "<td align='center' height='30'>" .$row['cash_status']. "</td>";
echo "<td align='center' height='30'>" .$row['cash_id']. "</td>";
echo"<td height='30'><a href= cadvance_approval.php?id=".$row['emp_id']."&cash_id=".$row['cash_id']."><img src='../img/view_user.png' width='20' height='20'></a></td>";
echo "</tr>";
}
echo "</table>";
?>
感謝。
你能告訴我們打印這張表的代碼嗎? – Halcyon
據我所知,**沒有**列沒有值... – sitilge
它很簡單,你可以採取'$計數器',並實現這一點 –