CodeIgniter2.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'] = "«";
$config['next_link'] = "»";
// $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 );
}