Link to home
Start Free TrialLog in
Avatar of daisydoos
daisydoos

asked on

Building up a query string for sorting purposes dynamically from select elements

Hi,

Having used the jquery tablesorter plugin for pagination and sorting purposes on a site, the client wants to use PHP now. Pagination is not a problem at all  - but I need an efficient way to build the query string for sort purposes when I want to be able to sort the list based on (eg) price, name. I need to be able to potentially add extra select elements (or possibily even check boxes at some stage) so the code needs to be able to handle that.

What I need to avoid is repeated occurences of the parameters in the query string eg
?sort=true&priceOrder=1&nameOrder=0&priceOrder=1
which happens if you use something like window.location.href in the jquery - i would like the string to be converted to in this instance
?sort=true&nameOrder=0&priceOrder=1

Any help much appreciated!

Cheers,

Daisy



ASKER CERTIFIED SOLUTION
Avatar of Garry Glendown
Garry Glendown
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of daisydoos
daisydoos

ASKER

Hi,

Many thanks for getting back to me - really appreciate it. I will get back to you when I've had a chance to look at your comments. Zappafan - the sorting is done by PHP but I need to pass the values to the query string each time I change a select variable - and this needs to be done using JS. I can build the query string - as described in my initial message but I was just trying to remove repeated occurences of parameters (eg nameOrder) as you build the url up. I know it doesnt actually matter when you are using $_GET, but it's just a case of keeping the urls short and tidy.

Cheers,

Daisy