View Full Version : Ascending Order?

08-01-2007, 06:26 PM
I wrote this program a while ago for the museum I work at. We may now actually use this program so I dug it up and was going to polish it up. Right now this code grabs information off of the database and displays it in a table. I was wondering how I could make it so that you can make it order a column if you click on the header?

<?php include("includes/connect.php");

$result = mysql_query("SELECT * FROM artifacts");

echo "<table border='1'>
<th>Accession #</th>


while($row = mysql_fetch_array($result))
echo "<tr>";
echo "<td>" . $row['category'] . "</td>";
echo "<td>" . $row['artifact'] . "</td>";
echo "<td>" . $row['first_name']," ",$row['last_name'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['accession']. "</td>";
echo "<td>" . '<a href="item.php?acc='.$row['accession'].'">View More</a>' . "</td>";
echo "</tr>";
echo "</table>";


Nevermind I got it to work. I kept trying the stuff I had found in my previous search, and it just took a little tweaking. Thank you.
If anyone else is searching, this may help you http://www.phpfreaks.com/mysqlref/16.php.