matt1988
08-01-2007, 05: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?
<html><center>
<?php include("includes/connect.php");
include("header.php");
include("includes/template.php");
$result = mysql_query("SELECT * FROM artifacts");
echo "<table border='1'>
<tr>
<th>Category</th>
<th>Artifact</th>
<th>Donor</th>
<th>Location</th>
<th>Accession #</th>
</tr>";
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>";
mysql_close($con);
?>
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.
<html><center>
<?php include("includes/connect.php");
include("header.php");
include("includes/template.php");
$result = mysql_query("SELECT * FROM artifacts");
echo "<table border='1'>
<tr>
<th>Category</th>
<th>Artifact</th>
<th>Donor</th>
<th>Location</th>
<th>Accession #</th>
</tr>";
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>";
mysql_close($con);
?>
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.