Page 1 of 1

how to use Jump menu to sort my search results

Posted: Mon Nov 01, 2010 8:33 am
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?

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

Posted: Mon Nov 01, 2010 12:35 pm
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.