I got a MySql database that I do some potentially large queries to. The data I get from the query is stored in a 2D array in PHP which then generates a HTML table for the user to see. Currently I'm trying to implement a way to sort the data in various ways for the user. Of course I could just call the query again and tell it to sort in a different way, but I figure this would probably not be a very efficient way. My idea is to cache the data in some way and then call a javascript each time the data should be sorted in a new way to get the result. Unfortunately I don't know how to do that... :)
So, my questions are:
- Is it a good idea to do it that way?
- How could I implement this feature?