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
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;

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.