Sorting my records using the Jump menu

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

Sorting my records using the Jump menu

Post by adsegzy »

Hello Friends,

I have a page hwere i echo out my search results from my mysql database. by defualt the echo results are sort by date desc. but i want to jump menu that will have the following;

Sort by Date in Ascendind order
Sort by Date in Descending order
Sort by IP in Ascendind order
Sort by IP in Descending order
Sort by Location

What i want to do is that if i select "Sort by IP in Ascendind order" from the jump menu, the result on the page should be sorted by IP in ascending order, or if i select "Sort by Location" the result should be sorted by Location on this same page.

Plsease how do i go about it?

Regards
adsegzy
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: Sorting my records using the Jump menu

Post by Gargoyle »

create a dropdown that will call the script like

Code: Select all

search.php?sort=1
and in your script, put something along the lines of this pseudocode

Code: Select all

if($sort==1)
{sort by date}
if($sort==2)
{sort by something else}
Post Reply