0

hiee

i want to sort a column on the click of hyperlink of header i m doing it by sql query so how so i write javascript for this so that i can call on onclick of hyperlink and column get sorted

3
Contributors
2
Replies
8
Views
3 Years
Discussion Span
Last Post by JorgeM
0

so when you say you have a column, I assume that you are presenting the data in an HTML Table element? I dont see this as a PHP or SQL issue/question.

i think a viable approach is to handle this client side. If you are a familiar with jQuery (a javascript library), there are tons of scripts out there to help you sort data in a table. For example, take a look at this one. I think something like this is what you may be looking for.

http://tablesorter.com/docs/

otherwise if you are going to try to sort the data server side, you would have to have to initiate a postback, send PHP some value that it knows what columun to sort, then requery SQL to generate a new table based on that column sort. I dont think this would be a good approach.

Again, try to handle this client side.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.