Prevent duplicate sort, order and page GET VARs in the URL when Clicking to Sort a field or Clicking a page number. We now unset the GET VAR arrays before recreating the URL GET Strings

This commit is contained in:
johnnyq
2023-07-08 14:40:00 -04:00
parent e7572c9e8f
commit 1bacabc72b
45 changed files with 58 additions and 47 deletions

View File

@@ -58,12 +58,16 @@ if ($total_found_rows > 10) {
} else {
$next_class = "disabled";
}
$url_query_strings = http_build_query(array_merge($_GET, array('page' => $i)));
$get_copy = $_GET; // create a copy of the $_GET array
//unset($get_copy['page']);
// Unset Array Var to prevent Duplicate Get VARs
unset($get_copy['page']);
$url_query_strings_page = http_build_query($get_copy);
$prev_page = $page - 1;
$next_page = $page + 1;
if ($page > 1) {
echo "<li class='page-item $prev_class'><a class='page-link' href='?$url_query_strings&page=$prev_page'>Prev</a></li>";
echo "<li class='page-item $prev_class'><a class='page-link' href='?$url_query_strings_page&page=$prev_page'>Prev</a></li>";
}
while ($i < $total_pages) {
@@ -74,12 +78,12 @@ if ($total_found_rows > 10) {
} else {
$page_class = "";
}
echo "<li class='page-item $page_class'><a class='page-link' href='?$url_query_strings&page=$i'>$i</a></li>";
echo "<li class='page-item $page_class'><a class='page-link' href='?$url_query_strings_page&page=$i'>$i</a></li>";
}
}
if ($page <> $total_pages) {
echo "<li class='page-item $next_class'><a class='page-link' href='?$url_query_strings&page=$next_page'>Next</a></li>";
echo "<li class='page-item $next_class'><a class='page-link' href='?$url_query_strings_page&page=$next_page'>Next</a></li>";
}
?>