Below is a pagination function which I use on my website. Everything is OK but it doesn't look good for search engines. This function displays page number/links like this:
1 2 3 4 ...100
Page # 1 shows the newest content but after some time this content will move to page #2, then to page #3 etc.
I want to display pages in this way:
100 99 98 97 ... 1
Can get such a function somewhere? Probably someone could help me to change the function below so that it shows pages/links in reverse order? I tried ir myself but no success.
Thank you.
function paginate($pag,$count,$link,$step) {
$str = '';
if ($step < $count) {
$mesdisp = $step;
$max = $count;
$pag = ($pag > $count) ? $count : $pag;
$pag = ( floor( $pag / $mesdisp ) ) * $mesdisp;
if ((6 % 2) == 1) $pc = (int)((6 - 1) / 2);
else $pc = (int)(6 / 2);
if ($pag > $mesdisp * $pc)
$str.= '<a href="/'.$link.'pag=0">1</a>';
if ($pag > $mesdisp * ($pc + 1)) $str.= "...";
for ($nCont=$pc; $nCont >= 1; $nCont--)
if ($pag >= $mesdisp * $nCont) {
$tmpStart = $pag - $mesdisp * $nCont;
$tmpPage = $tmpStart / $mesdisp + 1;
$str.= '<a href="/'.$link.'pag='.$tmpStart.'">'.$tmpPage.'</a>'; }
$tmpPage = $pag / $mesdisp + 1;
$str.= "<span class=\"current\">".$tmpPage."</span>";
$tmpMaxPages = (int)(($max - 1) / $mesdisp) * $mesdisp;
for ($nCont=1; $nCont <= $pc; $nCont++)
if ($pag + $mesdisp * $nCont <= $tmpMaxPages) {
$tmpStart = $pag + $mesdisp * $nCont;
$tmpPage = $tmpStart / $mesdisp + 1;
$str.= '<a href="/'.$link.'pag='.$tmpStart.'">'.$tmpPage.'</a>';}
if (($pag + $mesdisp * ($pc + 1)) < $tmpMaxPages) $str.= "...";
if (($pag + $mesdisp * $pc) < $tmpMaxPages) {
$tmpPage = $tmpMaxPages / $mesdisp + 1;
$str.= '<a href="/'.$link.'pag='.$tmpMaxPages.'">'.$tmpPage.'</a>'; }
}
return $str;