**When there are a sufficient number of pages present, a Last Page link is added. When you navigate away from the first page, a previous page link is added. When you navigate past the second page, a first page link is added.
This code hasn't been tested all that much. It has worked fine for me, but I have only used it in limited situations and only in development. If you have any problems, please let me know.**
<?php
class display {
function pagination($rows, $per_page, $current_page, $page_link) {
global $core,$C;
// Create a Page Listing
$this->pages = ceil($rows / $per_page);
// If there's only one page, return now and don't bother
if($this->pages == 1) {
return;
}
// Pagination Prefix
// Should we show the FIRST PAGE link?
if($currentpage > 2) {
$output .= "<<";
}
// Should we show the PREVIOUS PAGE link?
if($currentpage > 1) {
$previouspage = $currentpage - 1;
$output .= " page=". $previous_page ."/\" title=\"Previous Page\"><";
}
// Current Page Number
$output .= "[ ". $currentpage ." ]";
// Should we show the NEXT PAGE link?
if($currentpage < $this->pages) {
$nextpage = $currentpage + 1;
$output .= ">";
}
// Should we show the LAST PAGE link?
if($current_page < $this->pages - 1) {
$output .= " pages ." \"="" title="\"Last" page\"="">>>";
}
// Return the output.
return $output;
}
}
$display = new display;
echo $display->pagination("http://mysite.com/index.php");
?>
0 Comment(s)