Re-sorting data in a table



My first post, Lets see how it does...

I have a page that displays the output from a DB table to an HTML Table. Which works fine. But, I want to be able to sort the data by clicking in the column headings.

I can see that all I need to do to achieve this is change the SQL statement to sort by the column name, but what is the best method of doing this within the page? Will I have to reload it and pass it a new value for the $query variable? if so what method do I use to do this?

Help would be great!!

Thanks :D