Title: CodeIgniter Pagination does not work as expected
Tags: php;codeigniter;pagination
Question: I'm creating a pagination in CodeIgniter 2.1.3. The url of every link is missing their base_url I have created for them. For example, they show only localhost/2, or localhost/3,... on those links respectively when I hover on them.
Here is my Controller:
public function default_page() {
$values = $this-&gt;maction-&gt;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-&gt;maction-&gt;get_all_num_rows();
$config['per_page'] = 10;
$config['num_links'] = 5;
$offset = 3;
// I also tried
// $offset = $this-&gt;uri-&gt;segment( 3 );
$config['last_tag_open'] = "<div class='pagination'&gt;";
$config['last_tag_close'] = "</div&gt;";
$config['prev_link'] = "&amp;laquo;";
$config['next_link'] = "&amp;raquo;";
// $config['use_page_numbers'] = TRUE;
$this-&gt;pagination-&gt;initialize( $config );
$data['posts'] = $this-&gt;maction-&gt;get_all_posts( $config['per_page'] , $offset );
$data['pagination'] = $this-&gt;pagination-&gt;create_links();
$this-&gt;load-&gt;view('template/header');
$this-&gt;load-&gt;view('default', $data);
$this-&gt;load-&gt;view('template/footer');
Here is my Model:
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-&gt;db-&gt;query( $sql );
Comment: What is the `base_url` and `index_page` set to in your `config/config.php` file?


Here is another answer: I think it should be base_url() instead of base_url.

Here is another answer: It should be $config['base_url'], not $congif

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:01/11/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php><codeigniter><pagination>', 'Title': 'CodeIgniter Pagination does not work as expected', 'ViewCount': 340, 'id': 14282350, 'user_AboutMe': "<p>I am a full stack developer from Cambodia.\nI'm passionate about creative ideas, beautiful user experience, and simple solutions to complex business problems.</p>\n", 'user_AccountId': 421306.0, 'user_DisplayName': 'Tepken Vannkorn', 'user_Reputation': 9560.0, 'user_Views': 1083.0, 'user_id': 799478.0}}