The $_SERVER['REQUEST_URI']
brings the entire url, including the query string, if concactenate it will duplicate the pag=
and there will be cases where the url will look like this .php&pag=
.
Do so:
<?php
//Pega a URL da página atual .php
$fullUrl = $_SERVER['PHP_SELF'];
//Se não tiver _GET então usa o ?
$signConcat = '?';
//Verifica se tem variaveis _GET
if (empty($_GET) === false) {
//Copia variáveis
$gets = $_GET;
//Verifica se existe 'page' e remove ela
if (isset($gets['page'])) {
unset($gets['page']);
}
//Se tiver qualquer _GET adiciona o & no prefixo
$signConcat = '&';
//Adiciona ao $fullUrl o $gets "formatado"
$fullUrl .= '?' . http_build_query($gets, '', '&');
}
?>
And call in your loop like this:
<a href="' . $fullUrl . $signConcat . 'page=' .$i. '">'.$i. '<span class="sr-only">(current)</span></a></li>';
I don’t understand why the double vote ...
– gmsantos