我正在使用此代码从特定类别中检索所有帖子。此代码显示前 20 个结果,然后当用户将页面滚动到底部时,它会加载接下来的 20 个结果,依此类推。不幸的是,当我单击某个类别时,前 20 个结果是正确的,但下一个结果是来自其他类别的混合。下面是我使用的代码。我究竟做错了什么 ??
function category($category="''") {
$userID = false;
$order = false;
$limit = $this->config->item('post_load_limit');
$page = $this->uri->segment(4, 1);
$nextOffset = ($page -1) * $limit;
$nextPage = $page +1;
$sql = "SELECT *
FROM
posts";
if ($category)
$sql .= ' WHERE
album_id in (SELECT id
FROM
album
WHERE
category ="'.$category.'")';
if ($order) {
$sql .= " ORDER BY
'$order'";
} else {
$sql .= " ORDER BY time DESC";
}
$sql .= " LIMIT $nextOffset,$limit";
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
$row = $query->result();
}
if (!empty($row))
$data['row'] = $row;
else
$data['row'] = false;
$data['title'] = 'Welcome';
再次感谢您的宝贵帮助!