sorting by column

Discussion in 'PHP' started by mnymkr, May 8, 2007.

  1. #1
    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?
     
    mnymkr, May 8, 2007 IP
  2. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #2
    yes , you can .

    you can add a variable called : sort=by-the-variable and you send this variable to the query .
     
    commandos, May 8, 2007 IP
  3. mnymkr

    mnymkr Well-Known Member

    Messages:
    2,328
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    120
    #3
    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....
     
    mnymkr, May 8, 2007 IP
  4. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #4
    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"
     
    commandos, May 8, 2007 IP
  5. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #5
    T0PS3O, May 8, 2007 IP
    commandos likes this.
  6. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #6
    sorry lol what i posted was for a get not for a POST ...

    Thank's TOPS30 ...
     
    commandos, May 8, 2007 IP