how to use Jump menu to sort my search results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

how to use Jump menu to sort my search results

Post by adsegzy »

Am having a website where i need to retrieve record from the database. once the page loads the record will be displayed according to the ID (the primary key) descending order, but if the visitor select DATE from the jump menu drop-down, the record should be sorted by the date, if the visitor select NEW TO OLD from the jump menu drop-down the record should be sorted from the latest to the old, if the visitor select PRICE from the jump menu drop-down, the record should be sorted by the price, etc pls how do i do this?
mikecampbell
Forum Commoner
Posts: 38
Joined: Tue Oct 12, 2010 7:26 pm

Re: how to use Jump menu to sort my search results

Post by mikecampbell »

You have options.

1. When the user selects a new sort criteria you could load the same URL with the sort criteria as an additional parameter. You'd have to issue the SQL query again, but this time use ORDER BY to return the records in the new order.

2. You could use JavaScript with the help of a library like jQuery to resort the items on your page. This way the page doesn't need to reload.
Post Reply