Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add a link to change sort order?

Status
Not open for further replies.

bsanderson

IS-IT--Management
Mar 17, 2020
4
0
0
US
I have a php page that outputs a list sorted by a field in ascending order. In order to sort the output in descending order, I have a link to an identical page with DESC added to the end of the query. I would like to do this with a single page. How can I add a link to the page that would reload the page with a different query.

Any help will be greatly appreciated.
 
You'd create links like...

for an ascending sort.
for a descending sort.

Then you'd process them on page.php with...
Code:
if ((isset($_GET['sort'])) AND ($_GET['sort'] == "A")) { $query = $query . " ORDER BY something ASC"; }
if ((isset($_GET['sort'])) AND ($_GET['sort'] == "D")) { $query = $query . " ORDER BY something DESC"; }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top