Click to See Complete Forum and Search --> : [RESOLVED] guestbook...
Justa Lol
Dec 12th, 2009, 05:03 AM
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?
SambaNeko
Dec 12th, 2009, 10:54 AM
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:
//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.
Justa Lol
Dec 13th, 2009, 03:20 AM
ok thanks, thats what i needed to know. :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.