Hello, Im trying to get the following working:
I have a list, loaded from a MySQL database, and I have links to sort the list by name, date, id, etc.
The structure to determine if its going to sort everything ASC or DESC is something like
if ($_GET['order'] == "ASC") $order = "DESC";
else $order = "DESC";
$sort = $_GET['sort'];
//here, $order could be either ASC or DESC
//and $sort could be 'name', 'date', 'id', etc.
then the links look like this
//for this example,
//$sort = "name";
//$order = "ASC";
echo '<a href="?sort='.$sort.'&order='.$order.'">$sort</a>';
so anyway, when you click on that, the new address goes from, lets say,
http://localhost/path/to/file/index.php
to
http://localhost/path/to/file/index.php?sort=name&order=ASC
Everything 'good' so far.
The thing now is, I added a variable to know wether the list should display all the items in it or just some of them and page to display the rest.
so I have a link like this:
<a href="?show=all">Show All</a>
The address used to look like this:
http://localhost/path/to/file/index.php?sort=name&order=ASC
and now it is [after you click "Show All"]
http://localhost/path/to/file/index.php?show=all
I know the code I have is working, its just doing what its supposed to, but what I want is to get this:
http://localhost/path/to/file/index.php?sort=name&order=ASC&show=all
in other words, get everything after '.php?' and add '&show=all'
and the same for the sorting; if I have '.php?show=all', add '&sort=$sort&order=$order'
So bleh thats about it, thanks in advance for any help,
-javier