php - Can't load the database result properly using codeigniter pagination class -


i don't know i'm doing wrong here, can please help, here's controller.. want display database result according pagination set.

function post_paginates($offset = 0){     $this->load->model('users_model');     $this->load->library('pagination');      $limit = 3;     $config['base_url'] = 'http://localhost/blog_ext/index.php/welcome/post_paginates/';     $config['total_rows'] = $this->users_model->totalcountpost();     $config['per_page'] = $limit;     $config['num_links'] = 2;     $config['uri_segment'] = 4;     $config['page_query_string']=true;      $config['query_string_segment'] = 'pageno';      $this->pagination->initialize($config);     $data['offset'] = $offset;      $posts = $this->users_model->get_post($limit, $offset);      $data = array(         'posts' => $posts,         'pages' => $this->pagination->create_links()     );      $this->load->view('post_paginates', $data); } 

and here's model

function get_post($limit, $offset){     $query = $this->db->get('news', $limit, $offset);     return $query->result(); } 

and here's view

<div id="posts">     <?php      if(isset($posts)){         foreach ($posts $titles) {             echo $titles->headline;             echo "<br>";         }     }     ?> </div> <div id="pages">     <?php echo $pages;?> </div> 

thanks in advance.. :-)

use

$offset = $this->input->get('pageno');  

for offset.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -