Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ascending Order?

    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?

    Code:
    <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.
    Last edited by matt1988; 08-01-2007 at 06:14 PM. Reason: got it fixed.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •