Making Sortable Displays
There’s one final feature that I want to add to view_users.php while I’m at it. In its current state the list of users is displayed in order by the date they registered. It would be nice to be able to view them by name as well.
From a MySQL perspective, accomplishing this task is easy: just change the ORDER BY clause. Therefore, all I need to do is add some functionality in PHP that will change the ORDER BY clause. The logical way to do this is to link the column headings so that clicking them changes the display order. As you hopefully can guess, this involves using the GET method to pass a parameter back to this page indicating the preferred sort order.
To take this concept just a little bit further, I want the sorting ...
Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.