0

我正在CodeIgniter 2.1.3中创建分页。每个链接的 url 都缺少我为它们创建的 base_url。例如,当我将鼠标悬停localhost/2在它们上时,它们仅显示或localhost/3,...在这些链接上。

这是我的控制器:

public function default_page() {
    $values = $this->maction->get_user_info( $_SESSION['id'] );
    if ( $values ) {
        $congif['base_url'] = base_url()."home/default_page/";
        // I aslo tried
        // $congif['base_url'] = site_url("home/default_page/");
        $config['total_rows'] = $this->maction->get_all_num_rows();
        $config['per_page'] = 10;
        $config['num_links'] = 5;
        $offset = 3;
        // I also tried
        // $offset = $this->uri->segment( 3 );
        $config['last_tag_open'] = "<div class='pagination'>";
        $config['last_tag_close'] = "</div>";
        $config['prev_link'] = "&laquo;";
        $config['next_link'] = "&raquo;";
        // $config['use_page_numbers'] = TRUE;
        $this->pagination->initialize( $config );                   
        $data['posts'] = $this->maction->get_all_posts( $config['per_page'] , $offset );
        $data['pagination'] = $this->pagination->create_links();

        $this->load->view('template/header');
        $this->load->view('default', $data);
        $this->load->view('template/footer');
    }
}

这是我的模型:

public function get_all_posts( $per_page, $offset ) {
    $sql = "SELECT * FROM user INNER JOIN content 
            ON user.user_id = content.crby ORDER BY 
            content.content_id DESC LIMIT $per_page, $offset";
    return $this->db->query( $sql );
}
4

2 回答 2

1

应该是$config['base_url'],不是$congif

于 2013-01-11T20:08:32.997 回答
0

我认为它应该是 base_url() 而不是 base_url。

于 2013-01-11T16:29:54.333 回答