Results 1 to 3 of 3

Thread: [RESOLVED] guestbook...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Resolved [RESOLVED] guestbook...

    i've made a guestbook, now when the comments reach over 20 i want only 20 comments to display on 1 site, how can i do this?

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: guestbook...

    Completely depends on the mechanism used for displaying comments. If you're using MySQL, I'd suggest using the LIMIT clause on your query that gets the comments:
    Code:
    //use a querystring variable to change this per page:
    $page = 1;
    
    $sql = "SELECT * FROM comments ORDER BY id DESC LIMIT ".(($page-1)*20).",20";
    The first argument of LIMIT is an offset, and the second is the number of rows you want to return. The second argument is obvious: 20. The first one needs to be calculated depending on what "page" of records you want to get: subtract 1 from the page number to account for a 0-based index, then multiply by the number of records per page.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Re: guestbook...

    ok thanks, thats what i needed to know.

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