Let's say I have a page called "comments.php", and the layout that matters is like this:
Code: Select all
$sql = mysql_query("SELECT * FROM comments ORDER BY lastpost DESC");
while($r = mysql_fetch_array($sql)) {
echo "$thefreakingcomments";
}Moderator: General Moderators
Code: Select all
$sql = mysql_query("SELECT * FROM comments ORDER BY lastpost DESC");
while($r = mysql_fetch_array($sql)) {
echo "$thefreakingcomments";
}Code: Select all
SELECT COUNT(*) FROM commentsCode: Select all
SELECT ... LIMIT $start, $countCode: Select all
<?php
// $page: page number
$page = (isset($_GET["page"]) ? intval($_GET["page"]) : 1);
if ($page < 1) $page = 1; // adjust if it's too small
// $count: number of comments per page
$count = 50;
// $comments: total number of comments
list($comments) = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM comments"));
// $pages: number of pages of comments
$pages = ceil($comments / $count);
if ($page > $pages) $page = $pages; // adjust if it's too large
$start = ($page - 1) * $count;
$sql = mysql_query("SELECT * FROM comments ORDER BY lastpost DESC LIMIT $start, $count");
while ($r = mysql_fetch_array($sql)) {
echo "the freaking comments";
}