Jump to content

problem with page counter


dr_ghost

Recommended Posts

plz anyone help me in making this counter good the original one i'm using is like that

6usgoqov4uqlv2myiqqg.gif

and the one i want to be modified like that

mud9n5kkjxb5nnewco.gif

and the original code used is that

 

<?

echo"<div class='pagi'>";

 

for($i=1;$i<=$pages;$i++)

{

if($page==$i) echo"<span class='current'> $i& nbsp;</span>";

else

{

echo " ";

 

echo"<a class='paginate' href='index.php?page=$i'>  $i </a>";

}

}

if($page>1)

{

$prev=$page-1;

echo " ";

echo"<a class='paginate' href='index.php?page=$pre v'>   « Prev   </a>";

}

 

 

 

if($page<$pages)

{

$next=$page+1;

echo"  ";

echo"<a class='paginate' href='index.php?page=$nex t'>   Next »   </a>";

}

 

echo"</div>";

?>

 

 

plz any one give me the modified code to be like modified image

Link to comment
https://forums.phpfreaks.com/topic/158392-problem-with-page-counter/
Share on other sites

Lol! You want right to left pager.

 

Something like this should work:

$show_pages=20; // this will show max 20 buttons
$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1; // safely read current page

if($pages<$show_pages){
// if we have only a few pages
$show_pages=$pages;
}

// get the fist page
$start_from = 1;
$show_to_first=false;
if($current_page>$show_pages){
$show_to_first=true;
$start_from=$current_page-($show_pages/2);
}

$to_last_page_html="";
$to_first_page_html="";
if($show_to_first){
// here you populate $to_first_page_html with html of  ... and button to first page
}

if(($start_from+$show_pages)<$pages){
// here you populate $to_last_page_html with html of last page button and ...

}else if(($start_from+$show_pages)>=$pages){
$show_pages = ($show_pages/2)+$pages - $current_page;
}

// rearrange for sentence for left to right pager
echo $to_last_page_html;
for($i=($start_from+$show_pages);$i>=$start_from;$i--){
// your pager code here
}
echo $to_first_page_html;

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.