hi.
I wrote my own pagination function.
I stole several ideas from you. And added some new ideas.
See my attachement for a ScreenShot.
This function will be alright, if there are not too many pages.
Because it will display all page numbers.
For say less than 30-40 pages it may do well.
Of course details can be changed and added. Like style etc.
I will post function variant in this post
and non-function version in my next post.
Usage:
echo pagin( $pagenumber, $number_of_items, $per_page);
Code with example:
<?php
/// Pagination function
function pagin($currpage, $items, $perpage){
$p = $currpage;
$pmax= ceil($items/$perpage);
if($p<1||$p>$pmax) $p=1;
$prv=$p-1;
$nxt=$p+1;
$ret ='';
$ret.= "<table><tr>\n<td style=\"width:2.5em;text-align:right\">";
if($p!=1) $ret.="<a href=\"?page=$prv\">Prev</a>";
else $ret.=" ";
$ret.="</td><td>";
for($i=1;$i<=$pmax;$i++){
if($i==$p)$ret.="$i ";
else $ret.="<a href=\"?page=$i\">$i</a> ";
}
$ret.="</td><td style=\"width:2.5em;text-align:left\">";
if($p!=$pmax) $ret.="<a href=\"?page=$nxt\">Next</a>";
else $ret.=" ";
$ret.="</td>\n</tr></table>\n";
return $ret;
}// END Pagination function
///////////////////////////////////
$page=(isset($_GET['page'])&&ctype_digit($_GET['page']))? $_GET['page']:1;
$items = 75;
$perpage = 10;
echo pagin($page, $items, $perpage); //Pagination links, top
echo "<hr>\n<p><b>Page $page.</b></p>\n";
// Display Items
$start = 1+$perpage*($page-1);
for($i=$start;$i<($start+$perpage)&&$i<=$items;$i++){
echo $i.'<br />';
}
echo "\n<p><b>Page $page.</b></p>\n<hr>\n";
echo pagin($page, $items, $perpage); //Pagination links, bottom
?>