php - Pagination with codeignator not working properly -


i applied pagination shows whole result on 1 page or if applied limit in query showing same 20 results on every page....plz me

this controller file:

public function hhh($offset = 0 )    {        $sql_query  =   "select username valenth_user banned=1 limit 0,20";     $query = $this->db->query($sql_query)->result_array();      $data["pages"]=$query;      $this->load->library("pagination");       $config = array();     $row = count($pages);     $config['base_url'] = base_url().'/test/hhh/';     $config['total_rows'] = 120;     $config['per_page'] = 20;     $config['uri_segment'] = 3;      $this->pagination->initialize($config);               //$data['pages'] = $this-db-get('valenth_user', 10, $offset);     $this-load-library("pagination");     $this-template-load('template/template','onlinee',$data);      //$data['pages'] = $this->db->get($query, 10, $offset);          $query =    array_slice($query-result_array(),$rows,$config['per_page']);        } 

and view:

<?       $rows = count($pages);       foreach($pages $hhh)              {         $user = new user ($hhh['username'],'username');                  $hhh['username'] = $user->makelink();         echo $hhh['username']."<br>"; }    ?>  <?php echo $this-pagination-create_links(); ?> 

try this

model

public function get_users($limit,$offset) {     $sql_query  =   "select username valenth_user banned=1 limit $limit,$offset";     return $this->db->query($sql_query)->result_array();         }  public function get_total_users_count() {     $sql_query  =   "select username valenth_user banned=1 ";     $query      =   $this->db->query($sql_query);            return      count($query->result_array()); }    

controller

public function hhh()    {        $offset =   $this->uri->segment(3,0);     $limit  =   $this->uri->segment(4,20);       $this->mymodel->get_total_users_count();      $config['base_url']     =   site_url('test/hhh');     $config['total_rows']   =   $this->mymodel->get_total_users_count();     $config['per_page']     =   20;     $config['uri_segment']  =   3;      $this->load->library("pagination");       $this->pagination->initialize($config);                $data["pages"]  =   $this->mymodel->get_users($limit,$offset);     $data["links"]  =   $this->pagination->create_links();      $this->template->load('template/template','onlinee',$data);  } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -