SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sup

    I have a guestbook, pretty basic and average, just pulls results out of mysql ordered by date in PHP.

    How can i split into say 20 results a page with "prev" and "next" buttons..

    Cheerz
    J

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are a lot (i saw at least 5 threads) about this topic recently, you might want to do a search on that @SPF
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The basic premise lies in using LIMIT...the below example uses 20 results per page.

    SELECT * from table_name WHERE title LIKE "%$search%" LIMIT 20

    The "next" link would include "?page=1" in the URL string, and you'd have something like this to deal with it:


    $offset = $page * 20;
    $result = "SELECT * from table_name WHERE title LIKE "%$search%" LIMIT $offset, 20";


    Hope that helps.


Bookmarks

Posting Permissions

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