I have a table that contains data from my database. I was wondering if there was a way that I could make the headers (name, date joined, expiry date and fee) control the order of the data in both ascending and descending order. And make the which header is organizing the data currently look different (ie. when data is organized by name...name is bold while other headers are not). I've tried searching for how to do this...but have had no luck with actually accomplishing it.
I'd appreciate any help.
Thanks
Here is my code:
<?php
print'
<table class="myTable">
<thead>
<th scope="col"><h2>Name</h2></th>
<th scope="col"><h2>Phone Number</h2></th>
<th scope="col"><h2>Email</h2></th>
<th scope="col"><h2>Date Joined</h2></th>
<th scope="col"><h2>Expiry Date</h2></th>
<th scope="col"><h2>Fee Paid</h2></th>
<th scope="col"><h2>Edit</h2></th>
<th scope="col"><h2>Delete</h2></th>
</thead>';
$sql = "SELECT name, phone, email, date_joined, expiry_date, fee FROM customer ORDER BY name";
$qry = mysql_query($sql);
if (mysql_num_rows($qry) > 0) {
while ($rs = mysql_fetch_assoc($qry)) {
print'
<td>' . $rs['name'] . '</td>
<td>' . $rs['phone'] . '</td>
<td>' . $rs['email'] . '</td>
<td>' . $rs['date_joined'] . '</td>
<td>' . $rs['expiry_date'] . '</td>
<td>' . $rs['fee'] . '</td>
<td><a href="edit.php">Edit</a></td>
<td><a href="delete.php">Delete</a></td><tr>';
}
} else {
print '<h4>no result found</h4>';
}
print'
</table>';
?>