I'm trying to tweak some code that broke because of an SEO update - the site now uses a mod rewrite in apache to change the URL to a more SEO friendly one. The problem is that the code below returns the "index.php" page and not the SEO friendly one, so the pagination doesn't work.
When I change $link = $_SERVER['PHP_SELF'] to $link = $_SERVER['REQUEST_URI'] - the code works, but doesn't strip out the query string.
More coffee hasn't helped in 2 days. Anyone?
Code:function printResultSetLinks($numResults, $p_results_per_screen = RESULTS_PER_SCREEN) { $screen = (!empty($_REQUEST[SEARCH_GROUP]) ? $_REQUEST[SEARCH_GROUP] : 1); $queryString = "?" . $_SERVER['QUERY_STRING']; // Remove the SEARCH_GROUP param, if it was present. // this allows easier insertion of another SEARCH_GROUP param. $searchGroup = isset($_REQUEST[SEARCH_GROUP]) ? $_REQUEST[SEARCH_GROUP] : ""; if (strpos($queryString, "&" . SEARCH_GROUP . "=" . $searchGroup) >= 0) $queryString = str_replace("&" . SEARCH_GROUP . "=" . $searchGroup, "", $queryString); print("<p align=center><SMALL>"); // Again this means we are only displaying results in batches. // Here we give links to all batches. $firstBatch = ($screen - RESULT_RADIUS < 1) ? 1 : $screen - RESULT_RADIUS; $lastPossibleBatch = floor(($numResults - 1) / $p_results_per_screen) + 1; $lastBatch = ($firstBatch + (RESULT_RADIUS * 2 - 1) > $lastPossibleBatch) ? $lastPossibleBatch : $firstBatch + (RESULT_RADIUS * 2 - 1); // Print out the "Prev" link. if ($screen > 1) { $newQueryString = "$queryString&" . SEARCH_GROUP . "=" . ($screen - 1); $link = $_SERVER['PHP_SELF'] . $newQueryString; $output = "<a href=\"" . $link . "\">Previous</a>"; print($output . " \n"); } // Print the numbers that represent screen batches. for ($i=$firstBatch; $i<=($lastBatch > $firstBatch ? $lastBatch : -1); $i++) { if ($i > 1) print "| "; $newQueryString = $queryString . "&" . SEARCH_GROUP . "=" . $i; $link = $_SERVER['PHP_SELF'] . $newQueryString; $output = ($i != $screen) ? "<a href='$link'>$i</a>" : "$i"; print($output . " \n"); } // Print out the "Next" link. if ($screen < $lastBatch) { $newQueryString = "$queryString&" . SEARCH_GROUP . "=" . ($screen + 1); $link = $_SERVER['PHP_SELF'] . $newQueryString; $output = "<a href=\"" . $link . "\">Next</a>"; print($output . " \n"); }





Bookmarks