Possuo um site, de onde pretendo limitar o numero de paginas em visualização.
Exemplo:
1 | 2 | 3 | 4 | 5 | 5 | 7 | 8 | 9 | 10 | 11
quero reduzir isto para:
1 | 2 | 3 | 4 | ... | 10 | 11
Possuo o codigo, mas esta a dar dores de cabeça.
if(!empty($_GET[Start]))
{
$Start = $_GET[Start];
}
else
{
$Start = '0';
}
// limite de links
$ByPage = '13';
$rnav = mysql_query($qnav) or die(mysql_error());
$rows = mysql_num_rows($rnav);
if($rows > $ByPage)
{
$ListingTable .= "<table class=\"tlistnav\" border=0 cellspacing=0 align=center width=100% >";
$ListingTable .= "<tr><td align=center><font face=verdana size=2> | ";
$pages = ceil($rows/$ByPage);
$pagesLimit = 10;//Limite de páginas
$lowAllow = (int)($Start - ($pagesLimit / 2));
$start = ($lowAllow <= 0) ? 1 : $lowAllow;
$aboveAllow = $start + $pagesLimit;
$until = ($aboveAllow > $pages) ? $pages : $aboveAllow;
for($i = $start; $i <= $until; $i++)
{
$PageStart = $ByPage*$i;
$i2 = $i + 1;
if($PageStart == $Start)
{
$links[] = " <span class=CurrPageIdx>$i2</span>\n\t ";
}
elseif($PageStart < $rows)
{
$links[] = " <a class=BlackLink href=\"search.php?Start=$PageStart&c=$_GET[c]&s=$_GET[s]&search_kw=$_GET[search_kw]&CategoryID=$_GET[CategoryID]&search_district=$_GET[search_district]&search_place=$_GET[search_place]&search_city=$_GET[search_city]&PostID=$_GET[PostID]&zip=$_GET[zip]&old=$_GET[old]\">$i2</a>\n\t ";
}
}
$links2 = implode(" | ", $links);
$ListingTable .= $links2;
$ListingTable .= "| </td></tr>";
//JRM 2011 tablefix added </tr> to tlisnav
$ListingTable .= "</table><br><br>\n";
}
else // rows <= bypage (no navbar required)
{
$ListingTable .= "<br><br>\n";
}
Infelizmente o codigo esta a dar erro, pois a pagina 1 (primeira pagina) não aparece, e quando clico na pagina dois já so aparece 9 | 10 | 11 e não aparece a pagina 1 | ou posteriores.
Testando com limite de 5, o resultado inicial da paginação é: 2 | 3 | 4 | 5
Nas paginas seguintes da erro:
Warning: implode() [function.implode]: Invalid arguments passed in C:\Programas\xampp\htdocs\lergratis\classificados\search.php on line 511
linha 511 corresponde ao codigo:
$links2 = implode(" | ", $links);
Agradecia uma ajuda de quem tem pratica no assunto.
Obrigado pela gentileza em ajudar...