vaulient2
New Member
- Mar 12, 2013
- 27
- 3
Hey guys , So I found this code on a forum , it's for ubercms , it's a news comment system with pagination, but Idk how to conver it to work with Revcms. Here are the codes
I would love it if you would explain the concept of this code aswell , I'm trying to learn all this
Code:
$getComments = mysql_query("SELECT * FROM site_news_comments WHERE article = '".$news_article_id."' ORDER by id DESC");
Code:
$getComments = dbquery("SELECT * FROM site_news_comments WHERE article='" . $articleid . "'"); // Find all comments
$count = mysql_num_rows(getComments); // Results
$pages = ceil($count / 5); // Calculate pages
$offset = $page - 1; //
$offset = $offset * 5; // Comments per page
$getComments = dbquery("SELECT * FROM site_news_comments WHERE article = '" . $articleid . "' ORDER BY id ASC LIMIT 5 OFFSET " . $offset);
Code:
if ($page == 1)
{
echo "First ";
}
else
{
echo "<a href='articles?id=" . $articleid . "&page=" . 1 . "'>First</a> ";
}
for ($i = 1; $i <= $pages; $i++)
{
if (($page + 4) >= $i && ($page - 4) <= $i)
{
if ($i != $page)
{
echo'<a name="pages" href="' . WWW . '/articles?id=' . $articleid . '&page='.$i.'">'.$i.'</a> ';
}
else
{
echo "<b>" . $i . "</b> ";
}
}
}
if ($page == $pages)
{
echo "Last";
}
else
{
echo "<a href='article.php?id=" . $articleid . "&page=" . $pages . "'>Last</a>";
}
I would love it if you would explain the concept of this code aswell , I'm trying to learn all this