Hi all,
I have been able to create a table pulling data from a mySQL database, and have the sort hard coded into the script. What i want to do is allow someone to click the column title and have it sort by that one instead.
Below is my current code, any help would be great. Thanks
<?php
$Host = "localhost";
$User = "xxxx";
$Password = "xxxx";
$DBName = "mystuff";
$TableName = "my_music_cds";
$Link = mysql_connect ($Host, $User, $Password);
$Query = "SELECT * FROM $TableName order by Band, CD";
$Result = mysql_db_query ($DBName, $Query, $Link);
print ("<table border=1 width=\"75%\" cellspacing=2 cellpadding=2 align=center>\n");
print ("<tr align=center valign=top>\n");
print ("<td align=center valign=top><b>Band</b></td>\n");
print ("<td align=center valign=top><b>CD</b></td>\n");
print ("</tr>\n");
while ($Row = mysql_fetch_array ($Result)) {
print ("<tr align=center valign=top>\n");
print ("<td align=center valign=top>$Row[BAND]</td>\n");
print ("<td align=center valign=top>$Row[CD]</td>\n");
print ("</tr>\n");
}
mysql_close ($Link);
print ("</table>\n");
?>