I have done a few searches (including searching this board) and haven't come across an easy solution.
I have a page that spits out data from a db into a table. I would like the user to be able to sort by the column names. So here is what i've done.
if($_GET['sort'] == 'CELLNAME'){
$sort = "ORDER BY CELL_NAME";
}
if($_GET['sort'] == 'CHANNELS'){
$sort = "ORDER BY CHANNELS";
}
if($_GET['sort'] == 'DROPS'){
$sort = "ORDER BY DROPS";
}
This variable $sort gets appended to the query, and it spits out the data like it should. However here is where things are getting difficult for me.
If the user sorts by Channels the query string looks like:
page.php?sort=CHANNELS.
This will reload the page, sorting by CHANNELS.
If the user then wants to sort by DROPS, the query string then looks like:
page.php?sort=CHANNELS&sort=DROPS.
This is unacceptable, and confusing to troubleshoot.
Does this make sense? I hope so. Ok, there's another issue involved with this request.
Let's say the above problem doesn't exist. The user clicks on channels and it sorts by channels in ascending order. If the user clicks on channels again, to sort in descending order, it only sorts in ascending order. I realize it is because of this line:
$sort = "ORDER BY CHANNELS";
How do i give them the ability to sort in descending order?
Any help is greatly appreciated.
Thanks in advance.