title: pagination in codeigniter and passing values to a controller function but pagination not working
body: <p>controller file:</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Departments extends CI_Controller {
  
      function __construct()
      {
          parent:: __construct();
          $this-&gt;load-&gt;model('login_model','',TRUE);
          $this-&gt;load-&gt;model('pariskarmodel','',TRUE);
  
  
      }
  
      public function index($id)
      {
  
  
              $this-&gt;load-&gt;library("pagination");
              $config = array();
              $config["base_url"] = base_url() . "departments/index";
              $config["total_rows"] = $this-&gt;pariskarmodel-&gt;mng_departments_count_check($id);
              $config["per_page"] = 3;
              $config["uri_segment"] = 3;
              $this-&gt;pagination-&gt;initialize($config);
              $page = ($this-&gt;uri-&gt;segment(3)) ? $this-&gt;uri-&gt;segment(3) : 0;
              $data['news_data']=$this-&gt;pariskarmodel-&gt;mng_departments_check($config["per_page"],$page,$id);
              $data["links"] = $this-&gt;pagination-&gt;create_links();
              $this-&gt;load-&gt;view('departments',$data);
      }
  
  }
  
   ?&gt;
  </code></pre>
  
  <p>view Page:</p>
  
  <pre><code>&lt;u&gt;
   &lt;li&gt;&lt;a href="&lt;?php echo base_url();?&gt;departments"&gt;Departments&lt;/a&gt;&lt;/li&gt;
  &lt;li &gt;&lt;a href="&lt;?php echo base_url();?&gt;departments/index/1"&gt;Film&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="&lt;?php echo base_url();?&gt;departments/index/2"&gt;TV&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="&lt;?php echo base_url();?&gt;departments/index/3"&gt;Game&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="&lt;?php echo base_url();?&gt;departments/index/4"&gt;Commercials&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="&lt;?php echo base_url();?&gt;departments/index/5"&gt;Events &amp; Awards&lt;/a&gt;&lt;/li&gt;
               .
               .
               .
  &lt;li&gt;&lt;a href="&lt;?php echo base_url();?&gt;departments/index/15"&gt;Events &amp; Awards&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Model page:</p>
  
  <pre><code>function mng_departments_check($limit,$start,$id)
          {
  
          echo $sql="select * from tbl_departments where category='$id'  order by id DESC  limit $start,$limit";
  
              $query=$this-&gt;db-&gt;query($sql);
              return $query-&gt;result();
          }
          function mng_departments_count_check($id)
          {
              $sql="SELECT * FROM tbl_departments where category='$id' order by id DESC";
              $query=$this-&gt;db-&gt;query($sql);
              return $query-&gt;num_rows();
          }
  </code></pre>
  
  <p>result is:when am i click link one(file) sql query is :</p>
  
  <pre><code>select * from tbl_departments where category='1' order by id DESC limit 1,3
  </code></pre>
  
  <p>click link two(file) sql query is :</p>
  
  <pre><code>select * from tbl_departments where category='2' order by id DESC limit 2,3 
  </code></pre>
  
  <p>if am i click link 15 sql query is :</p>
  
  <pre><code>select * from tbl_departments where category='15' order by id DESC limit 15,3 
  </code></pre>
  
  <p>i cannot why category(category='15') is change in sql and pagination also not work.i put $this->uri->segment(4) also but not work .</p>