Berikut adalah contoh script untuk operasi display table dengan PHP

<?php
require_once “koneksi.php”;
$sql=”SELECT * FROM salary”;
$result=mysql_query($sql);
?>
<table border=0 cellpadding=”3″ cellspacing=”2″ bgcolor=”#cccccc” style=”font-family:Tahoma; font-size:12px;”>
<tr bgcolor=”#666666″ style=”color:#ffffff”>
<td>Staff No.</td>
<td>Name</td>
<td>Base Salary</td>
<td>Working Day</td>
<td>Salary per day</td>
<td>Tax</td>
<td>Total</td>
<td>&nbsp;</td>
</tr>
<?php
while ($data=mysql_fetch_array($result))
{
?>
<tr>
<td><?php echo $data[‘staffnumber’] ?></td>
<td><?php echo $data[‘staffname’] ?></td>
<td align=right><?php echo $data[‘basesalary’] ?></td>
<td align=right><?php echo $data[‘workingdays’] ?></td>
<td align=right><?php echo $data[‘salaryperday’] ?></td>
<td align=right><?php echo $data[‘tax’] ?></td>
<td align=right><?php echo $data[‘totalsalary’] ?></td>
<td>
<a href=”edit.php?s=<?php echo $data[‘staffnumber’] ?>”>Edit</a>
<a href=”delete.php?s=<?php echo $data[‘staffnumber’] ?>”>Delete</a>
</td>
</tr>
<?php
}
?>
</table>

Tags: