I'm not going to post my code because it is too long for anyone to want to read, and because I know that many of you more experienced developers will know exactly what I am talking about.
On my page when the "next page" link is clicked or when I click on any of the "sort" links my my query runs again and sorts the rersults accordingly, but without the previous query parameters specified. It simply leaves all values blank and sorts the results.
I fully understand why this is happeneing, but I don't know how to make it do what I want, which as you can guess would be to save the search criteria and run the query again with the appropriate sort or order condition.
I am still new to PHP, MySQL, and any type of developement in general. I have been researching for about a day now and I just haven't found my answer.
I know that I can use the $_SERVER['QUERY_STRING'] function, but what happens is that after doing so more than once my UTRL starts to repeat whichever data I append to the URL.
For instance prior to using $_SERVER['QUERY_STRING'] my URL looks like this:
http://localhost/Studio_manager/view_us ... bmit&subd=
then using this code to make my links:
Code: Select all
$my_url = '?' . $_SERVER['QUERY_STRING'];
//-------------------------------------------------------var_dump ($num_pages);
// Make the links to other pages, if necessary.
if ($num_pages > 1) {
echo '<br /><p>';
// Determine what page the script is on.
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous button.
if ($current_page != 1) {
echo '<a href="/Studio_manager/view_users.php' ;
echo $my_url ;
echo '&s='. ($start - $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Previous</a> ';
}
// Make all the numbered pages.
for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $current_page) {
echo '<a href="/Studio_manager/view_users.php' ;
echo $my_url ;
echo (($display * ($i - 1))) . '&np=' . $num_pages . '&sort=' . $sort .'">' . $i . '</a> ';
} else {
echo $i . ' ';
}
}
// If it's not the last page, make a Next button.
if ($current_page != $num_pages) {
echo '<a href="/Studio_manager/view_users.php' ;
echo $my_url ;
echo '&s='. ($start + $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Next</a>';
}after clicking on the "next" button I get a url like this:
http://localhost/Studio_manager/view_us ... first_name
at this point all is good, but then if I click on the "previous" sort link I get the following:
http://localhost/Studio_manager/view_us ... first_name
and it will just continue to grow. each time the link on that page is clicked, how can I get it to replace the query string instaed of appending to it?
Sorry for the long post!.
Thanks for reading all that.