View Single Post
  #2 (permalink)  
Old 07-09-2008, 02:32 AM
Tekerson Tekerson is offline
Member
 
Join Date: Jul 2008
Posts: 40
Default

Assuming your dataset is paginated, the simplest was is to make the column headings links that add a parameter to that determines the sort order when you pull the result from the database.
eg.
Code:
<a href="?column=name&order=asc">Name</a><a href="?column=email&order=asc">Email</a>
This can easily be extended by doing things such as:
  • making the links dynamic, allowing asc or desc ordering.
  • adding html/css to highlight the sorted row (eg. an arrow)
  • storing the order in a session/cookie so it is persisted if the user returns to the page
  • performing the lookup via JavaScript (Ajax) to avoid a page load.
Depends what you want to achieve.
__________________
Brenton Alker
Brisbane, Australia

http://blog.tekerson.com/
Reply With Quote