What you are trying to do is ridiculously easy, and something which I 
accomplished years ago. Basically every column heading needs to be output as 
a hyperlink which repeats the current page with the addition of 
"orderby=<column_name>" in the URL. This information appears in the $_GET 
array, so you just repeat the previous sql query with the addition of an 
ORDER BY clause.

This assumes that you have already taken care of caching the query and 
paginating the results.

You cannot do this in a separate class as it requires action in both the 
presentation (UI) and data access layers, and a single class is not allowed 
to operate in more than one layer.

Tony Marston

""Parham Doustdar"" <parha...@gmail.com> wrote in message 
Hello there,
I've been asked to create something like the tables you usually see, where 
the headers are actually links and when you click the links, the table gets 
sorted based on the header. Are there any classes that you know of that 
would do the job? My current idea is to return an array of the colomn which 
contains the data you want to sort on (like 'name') then sort the array and 
do something like:
for (i = 0; i < length(array); i++)
mysql_query("select * from table where 'name' = ${aray[i]}");
Any better algorithms anyone?
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
GoogleTalk: parha...@gmail.com
Twitter: PD90
email: parham90 at GMail dot com 

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to