|
-
Dec 12th, 2009, 06:03 AM
#1
Thread Starter
Fanatic Member
[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?
-
Dec 12th, 2009, 11:54 AM
#2
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.
-
Dec 13th, 2009, 04:20 AM
#3
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|