displaying a list from db, allowing users to 'sort by':...
I am creating a site and want to display the members list on a separate page. I want the user to be able to re-order this list by alphabet, by join date etc etc but I am not sure how to go about creating it.
I guess I would have to create different functions to deal with the re-ordering? One to re-order to alphabetical, one to re-order to join date?
Can anyone guide me on the best way to achieve this?
I'm really stumped at the moment been trying to think of a way for a good hour now but I find a potential issue with everything I have thought of.
ASC/DESC can be set toggled when using a link to draw your data. Typically you sort only by one specific type, so my querystring would include something like sort=field&dir=desc, where if no direction is set it assumes ASC.
Then you construct your links for each sortable header, and always provide a sort=fieldname. Then with the direction, you can either add it as whichever default you want, but the trick is to check and see if a sort is already selected, then invert the direction it goes for when you create that link.
Datagridviews are also used exclusively for these purposes. They are handled with a lot of ajax as well as PHP. You may be able to google up a generic data grid view for PHP.
Yea, i want it to dynamically load without having to reload the page. I'll read into retrieving data with AJAX, then I'll look into AJAX with PHP. I read my JS book last night which has a whole chapter dedicated to AJAX. I know the basic syntax to setup the data retrieval, but it's just working with the AJAX and PHP which I know absolutely nothing about.
Also, because I want the data to display dynamically, do I display the results with PHP first, then use the AJAX to change it? Or do I have to dynamically load the PHP with AJAX first, then change again with AJAX?