Loans - Lionel Trains - Mortgages - Loans - Credit Counseling

PDA

View Full Version : sorting by column


mnymkr
May 8th 2007, 10:30 am
I have read a ton of stuff on this and just can't get my brain around it. I am pulling two columns from MySQL by using post on a form.

The result look something like this

carat color cut
1.00 yellow round
2.00 clear emerald


how can I make the headers be links that when click resorts the table by that column?

can I do this with POST?

commandos
May 8th 2007, 10:33 am
yes , you can .

you can add a variable called : sort=by-the-variable and you send this variable to the query .

mnymkr
May 8th 2007, 10:36 am
ok the results are pulled from one post....

i am not sure hwo to make the link on the header change that variable....

even if this how to ask that question....

commandos
May 8th 2007, 10:42 am
what i meant was , what you can do is :

call the page (self) , add give it a post variable : $_GET["SortOption"];

and in the code you test :

if the $_GET["SortOption"]; isset you make a specific query .... if it's not you make the regular query .

adding the option can be as easy as just :

a href="index.php?SortOption=name"

T0PS3O
May 8th 2007, 10:46 am
Let AJAX sort it for you:

http://www.workingwith.me.uk/articles/scripting/standardista_table_sorting

Or change the form to GET to make your life easier.

commandos
May 8th 2007, 10:49 am
sorry lol what i posted was for a get not for a POST ...

Thank's TOPS30 ...