加载类别故障的结果

时间:2013-06-20 14:45:12

标签: php mysql

我正在使用此代码从speciefic类别中检索所有帖子。此代码显示前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';

再次感谢您的宝贵帮助!

0 个答案:

没有答案
相关问题