title: Pagination not working in CodeIgniter?
body: <p>Hi i am new in <code>CodeIgniter</code> and i have a problem in paginatation, i used the pagination class and here is my Controller:</p>
  
  <pre><code> public function user($page='user')
          {
              $this-&gt;load-&gt;helper('url');
              $this-&gt;load-&gt;library('pagination');
              if ( ! file_exists('application/views/admin/'.$page.'.php'))
              {
                  // Whoops, we don't have a page for that!
                  show_404();
              }
              //$data['user'] = $this-&gt;user-&gt;get_user($config["per_page"], $page);
              //$config = array();
              $config["base_url"] = base_url().'index.php/admin/user/';
              $config["total_rows"] = $this-&gt;user-&gt;record_count();
              $config["per_page"] = 5;
              $config["num_link"] = 3;
              $config['uri_segment'] = '5';
              $config['full_tag_open']='&lt;ul&gt;';
              $config['full_tag_close']='&lt;/ul&gt;';
              $config['prev_link'] = 'Prev';
              $config['prev_tag_open'] = '&lt;li&gt;';
              $config['prev_tag_close'] = '&lt;/li&gt;';
              $config['next_link'] = 'Next';
              $config['next_tag_open'] = '&lt;li&gt;';
              $config['next_tag_close'] = '&lt;/li&gt;';
              $config['cur_tag_open'] = '&lt;li class="current1"&gt;';
              $config['cur_tag_close'] = '&lt;/li&gt;';
              $config['num_tag_open'] = '&lt;li&gt;';
              $config['num_tag_close'] = '&lt;/li&gt;';
              $this-&gt;pagination-&gt;initialize($config);
              $offset = $this-&gt;uri-&gt;segment(5);
              //$page = ($this-&gt;uri-&gt;segment(3)) ? $this-&gt;uri-&gt;segment(3) : 0 ;
              //print_r($this-&gt;user-&gt;fetch_countries($config["per_page"],$this-&gt;uri-&gt;segment(3)));
              $data['user'] = $this-&gt;user-&gt;fetch_countries($config["per_page"],$offset);
              //$data['total_rows'] = $this-&gt;user-&gt;record_count($config["per_page"],$this-&gt;uri-&gt;segment(3));
              $data["links"] = $this-&gt;pagination-&gt;create_links();
              //print_r($data);
              //die();
              $data['base'] = $this-&gt;config-&gt;item('base_url');
              $data['css'] = $this-&gt;config-&gt;item('css');
              $this-&gt;load-&gt;view('admin/header', $data);
              $this-&gt;load-&gt;view('admin/'.$page,$data);
              $this-&gt;load-&gt;view('admin/footer',$data);
          }
  </code></pre>
  
  <p>The Model code:</p>
  
  <pre><code>   public function record_count() {
          return $this-&gt;db-&gt;count_all("user");
       }
       public function fetch_countries($limit, $start) {
          $query = $this-&gt;db-&gt;get("user",$limit, $start);
              return $query-&gt;result_array();
  
       }
  </code></pre>
  
  <p>And the view code:</p>
  
  <pre><code>&lt;?php foreach ($user as $user_detail): ?&gt;
          &lt;tr class="gray_line2"&gt;
              &lt;td class="sname2"&gt;&lt;?php echo $i ?&gt;&lt;/td&gt;
              &lt;td class="sname2"&gt;&lt;?php echo $user_detail['name'] ?&gt;&lt;/td&gt;
              &lt;td class="sname2"&gt;&lt;?php echo $user_detail['username'] ?&gt;&lt;/td&gt;
              &lt;td class="sname2"&gt;&lt;?php echo $user_detail['email'] ?&gt;&lt;/td&gt;
              &lt;td class="sname2"&gt;&lt;?php echo $user_detail['contact'] ?&gt;&lt;/td&gt;
              &lt;td class="sname2"&gt;&lt;?php echo $user_detail['dob'] ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;div class="action"&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;a href="user_detail?id=&lt;?php echo $user_detail['id'] ?&gt;" class="link" title="Details"&gt;&lt;img src="&lt;?php echo base_url();?&gt;images/detail.png" class="left"&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="user_edit?id=&lt;?php echo $user_detail['id'] ?&gt;" class="link" title="Edit"&gt;&lt;img src="&lt;?php echo base_url();?&gt;images/edit.png" class="left"&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="user_delete?id=&lt;?php echo $user_detail['id'] ?&gt;" class="link" title="Delete"&gt;&lt;img src="&lt;?php echo base_url();?&gt;images/cross.png" class="left"&gt;&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php 
           endforeach  ?&gt;     
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;div class="pagi"&gt;
  &lt;div class="pagination"&gt;
  &lt;?php echo $links; ?&gt;
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/8CzJS.png" rel="nofollow">Here is what i got</a></p>
  
  <p>This is the browser view, there only one page show, and when i click on the link of the second one, i got 404 error. i am using routes as followings</p>
  
  <pre><code>$route['admin/(:num)/(:any)'] = 'admin/user/$1';
  Or
  $route['admin/(:num)/(:any)/(:num)'] = 'admin/user/$1/$2/$3';
  </code></pre>