Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Advanced type of pagination

    Here's what I have right now:
    PHP Code:
    <?
    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:
    PHP Code:
    $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 ))))

  • #2
    New Coder
    Join Date
    Dec 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you
    Last edited by Prikid; 01-04-2006 at 11:30 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •