...

View Full Version : Advanced type of pagination



Prikid
01-04-2006, 10:06 PM
Here's what I have right now:


<?
if (!$_GET['offset'])
{
$offset = 0;
}
else
{
$offset = $_GET['offset'];
}


$show = DB_DataObject::factory('messages');
$numrows = $show->count('message_id');
$show->limit($offset,20);
$show->find();

$pages=intval($numrows/20);
if ($pages < ($numrows/20)){
$pages=($pages + 1);
}
if ($offset >= 20) {
$prevpage = $offset - 20;
?>
<a href="<?=$PHP_SELF;?>?offset=<?=$prevpage;?>" class="select">&laquo;</a>&nbsp;
<?
}
for ($i = 1; $i <= $pages; $i++) {
$newpage = 20*($i-1);
if ($newpage == $offset) {
?>
<span class="box"><? echo $i; ?></span>
<?
}
else {
?>
<a href="<?=$PHP_SELF;?>?offset=<?=$newpage;?>" class="select"><? echo $i; ?></a>&nbsp;
<?
}
}
//show next if not last
if (!(($offset/20) == ($pages - 1) ) && ($pages != 1) && $pages ) {
$newpage = $offset+20;
?>
<a href="<?=$PHP_SELF;?>?offset=<?=$newpage;?>" class="select">&raquo;</a>
<?
}
?>

What I need to do is modify that it shows only 10 pages with two links, one to the page '11' (or 21, 31, etc) and one with 'next 10 pages' link, which will link to next set of 10, but will not appear if the set is the last one
I've done the 'previous 10 pages' link:


$totalpages = intval($numrows/200);

if ($offset >= 200)
{
$prevpagetotal = $offset - 200;
?>
<a href="<?=$PHP_SELF;?>?offset=<?=$prevpagetotal;?>" class="select">&laquo; previous 10</a>
<?
}


but for some reason I'm not thinking completely through the script and cannot get 'next 10 pages' link done.

P.S. Please forgive me for not making it OO based ))))

Prikid
01-04-2006, 10:07 PM
Thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum