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?
Printable View
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?
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:
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.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";
ok thanks, thats what i needed to know. :)