Results 1 to 3 of 3

Thread: Pagination Tutorial?

  1. #1

    Thread Starter
    Banned
    Join Date
    Dec 2006
    Posts
    3

    Pagination Tutorial?

    Does anyone have a php next previous button tutorial they are willing to post?

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Pagination Tutorial?

    What is there to make a tutorial about? You limit the amount of data you fetch and keep track of the page you're on (best with a GET parameter). For example, a DB supporting the common LIMIT .. OFFSET SQL extension can be made to fetch just a subset of the rows like this:
    Code:
    $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
    
    $r = query('SELECT COUNT(*) FROM tablename WHERE criteria');
    $total = fetch($r, 1);
    
    $r = query('SELECT fields FROM tablename WHERE criteria LIMIT ? OFFSET ?',
        $rowsPerPage, ($page - 1) * $rowsPerPage);
    
    // Output $r
    
    if($page > 1) {
      // Output previous link
    }
    if($page * $rowsPerPage < $total) {
      // Output next link
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Pagination Tutorial?

    Quote Originally Posted by dreamerd
    Does anyone have a php next previous button tutorial they are willing to post?
    http://www.vbforums.com/showthread.p...51#post1988751
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width