AMDbuilder
Limp Gawd
- Joined
- Nov 16, 2006
- Messages
- 203
Hello,
I am trying to pull a list out of a DB and permit users to change the sort order of each column, but I can't seam to find anything on how to create the link that when clicked will change the sort order of that column.
Can anyone point me in the right direction as to how I would modify this code so the header name when clicked will change the sort order from an ID column to ASC for that column and then when click again it changes to DESC?
Thanks
AMDbuilder
I'm also open to programs to create the code to do things with DBs and I create a nice front end that would be another welcome alternative until I finally learn php.
I am trying to pull a list out of a DB and permit users to change the sort order of each column, but I can't seam to find anything on how to create the link that when clicked will change the sort order of that column.
Can anyone point me in the right direction as to how I would modify this code so the header name when clicked will change the sort order from an ID column to ASC for that column and then when click again it changes to DESC?
Thanks
AMDbuilder
I'm also open to programs to create the code to do things with DBs and I create a nice front end that would be another welcome alternative until I finally learn php.
Code:
<table>
<?php
$con = mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("table", $con);
$result = mysql_query("SELECT * FROM affiliated_club_list ORDER BY ID");
echo '<tr>' . "\n";
echo '<th class="top" scope="col">Club Name</th>' . "\n";
echo '<th class="top" scope="col">Location</th>' . "\n";
echo '<th class="top" scope="col">More Info</th>' . "\n";
echo '</tr>' . "\n";
while($row = mysql_fetch_array($result))
{
echo '<tr>' . "\n";
echo '<td>' . $row['Club Name'] . '</td>' . "\n";
echo '<td>' . " " . $row['Location'] . '</td>' . "\n";
echo '<td>' . " " . $row['More Info'] . '</td>' . "\n";
echo '</tr>' . "\n";
}
mysql_close($con);
?>
</table>