嗨,我有一个功能可以收集用户添加的帖子列表,并在页面中循环显示它。
我限制了显示的结果数量,即 LIMIMT 15,因此它不会在页面上溢出。但我现在想要做的是让所有其他结果(无论用户可以添加多少)显示在下一页上。每页只显示 15 个结果。因此,您最终会得到第 1 页、第 2 页、第 3 页等。
这是如何实现的?
function get_forum() {
global $connection;
global $profile_id;
$query = "SELECT *
FROM ptb_forum
WHERE ptb_forum.deleted ='0'
ORDER BY ptb_forum.date_added DESC
LIMIT 0 , 16";
$forum_set = mysql_query($query, $connection);
confirm_query($query, $connection);
return $forum_set;
}
<?php
$forum_set = get_forum();
?>
<br/>
<h3>Latest Forum Posts</h3>
<br/>
<?php
if(mysql_num_rows($forum_set) > 0) {
while ($forum = mysql_fetch_array($forum_set)) {
$age = days_from_date($forum['date_added']);
?>
<div class="prof-content-box-forum" id="reviews">
<div class="forum-content">
<?php echo "{$forum['content']}"; ?>
</div>
<div class="message_pic">
<?php echo "<a href=\"profile.php?id={$forum['from_user_id']}\"><img width=\"50px\" height=\"50px\" src=\"{$prof_photo}\"></a>";?>
</div>
<div class="forum-text">
<?php echo "Posted by {$forum2['display_name']}"; ?> <?php echo "".$age." days ago"; ?>
</div>
</div>
<? } } ?>