saeed_violinist Posted June 3, 2009 Share Posted June 3, 2009 Dear friends, I am not sure if my question is related to mysql! the problem is I have a normal table to list users in database, and in first row of table ofcourse there is a listing like this: Username | Full name | Join Date |.... now I want to make it somehow that by clicking on the, for example, full name, the table ordered by full name ( I mean A to Z), I know I can do it by making it to a hyperlink and adding somthing like "list.php?order=fullname", it will be listed as I want. but the question is how can I make it somehow that if user click on the link first time, it ordered by ASC and next click order it by DESC, is it done by javascript or something? Thanks. Link to comment https://forums.phpfreaks.com/topic/160759-order-by-table-and-listings/ Share on other sites More sharing options...
aschk Posted June 3, 2009 Share Posted June 3, 2009 Well you sort of answered your own question there. There are 2 ways to do it, depending on what you want/prefer. 1) Use a PHP query string to order the output at the backend, and then redisplay. 2) Use an internal client side javascript array , and onclick re-order it and redisplay the table. You want to tell your script whether you are ordering ASC or DESC, regardless of which method above you choose. i.e. list.php?order=fullname&direction=asc Link to comment https://forums.phpfreaks.com/topic/160759-order-by-table-and-listings/#findComment-848408 Share on other sites More sharing options...
saeed_violinist Posted June 3, 2009 Author Share Posted June 3, 2009 yeah I guess it is by javascript...any clue how to do it please? Link to comment https://forums.phpfreaks.com/topic/160759-order-by-table-and-listings/#findComment-848410 Share on other sites More sharing options...
aschk Posted June 3, 2009 Share Posted June 3, 2009 google? Link to comment https://forums.phpfreaks.com/topic/160759-order-by-table-and-listings/#findComment-848427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.