I'm having a problem with a paginator class. My page shows the correct amount of pages, but when I click on the link to go to the next page, the following page only shows the content of the first page, so I can't actually browse the pages.
This is the class that I'm using:
Code: Select all
<?php
class paginator {
var $current_page;
var $total;
var $per;
/*
Page should be made by uribuilder
So should the stuff in toolbuilder
This way I could choose to have either a raw or friendly setup ? vs /
*/
function paginator () {
}
function render() {
$this->current_page = $_GET['page']; if (empty($this->current_page)) { $this->current_page = 1; }
$number_of_pages = ceil($this->total / $this->per);
if ($number_of_pages > 1) {
$previous_page = $this->current_page - 1; if ($previous_page < 1) { unset($previous_page); }
$next_page = $this->current_page + 1; if ($next_page > $number_of_pages) { unset($next_page); }
}
echo '<div class="paginator">'."\n";
echo '<ul>'."\n";
for($i=1; $i < $number_of_pages+1; $i++) {
echo '<li><a title="Page '.$i.' of '.$number_of_pages.'"';
if ($this->current_page == $i) {
echo ' class="active"';
}
echo' href="';
echo uri_builder('page='.$i);
echo '">';
echo $i;
echo '</a></li>'."\n";
}
if ($previous_page) {
echo '<li><a title="Previous Page" href="'.uri_builder('page='.$previous_page).'">‹‹</a></li>';
}
if ($next_page) {
echo '<li><a title="Next Page" href="'.uri_builder('page='.$next_page).'">››</a></li>';
}
echo '</ul>'."\n";
echo '</div>'."\n";
}
}(results_per_page comes from a separate config file which is included in the output page)
Code: Select all
$paginator->total = count($mysql->mysql_array("SELECT * FROM productfiles"));
$paginator->per = $module['config']['display']['results_per_page'];
$order = order(array("orderby" => $_GET['orderby'],"order" => $_GET['order']));
$limit = limit(array("current_page" => $paginator->current_page,"per" => $paginator->per));
$query .= " SELECT * FROM productfiles";
$query .= " ".$order['query'];
$query .= " ".$limit['query'];
$paginator->render();
Could someone tell me what could be wrong with this?
cheers,
northernlight_10