I have a page that lists many records from a db.
Now I wish the user to be able to sort the list by the titles on the columns which I have done by passing an $orderby via <a href> as below:
Code: Select all
echo "<td height="15"><a href="".$_SERVERї'PHP_SELF']."?orderby=title">Title</a></td>";
echo "<td><a href="".$_SERVERї'PHP_SELF']."?orderby=creation_date">Creation date</a></td>";
echo "<td><a href="".$_SERVERї'PHP_SELF']."?orderby=counter">Views</a></td>";
echo "<td><a href="".$_SERVERї'PHP_SELF']."?orderby=product">Product</a></td>";Code: Select all
//this is not all the code just a snippet to show how I build the url string.
for ($i = 0; $i < $pages; $i++) {
$url = "index.php?pageid=" . $i;How do I build the url to either one of the above so that it takes into account any other actions the user may have performed on the page such as sort by title then clicks to view page 2, or is viewing page 2 then clicks to sort by date.
I hope I make sense.
I looked through the manual and I found $_SERVER["QUERY_STRING"]; which brings back any query after the foo.php but I am not sure how I should or can utilise this to help.
Could someone enlighten me please.