How to create pagination using dropdown option in codeigniter -


i want create pagination using codeigniter.problem can't show record according value dropdown option list.plz help.

here controller code:

    public function index($offset = 0)     {         $data['title'] = "basic crud function codeigniter";          if (!empty($post['limit'])) {              $limit = $this->input->post('limit');         }         else{             $limit = 1;         }          $offset = $this->uri->segment(3);          $records = $this->crud_mdl->get_paged_list($limit, $offset);          $config['base_url'] = base_url().'/crud/index/';         $config['total_rows'] = $this->crud_mdl->count_all();         $config['per_page'] = $limit;          $this->pagination->initialize($config);          $data['limit'] = $this->input->post('limit');         $data['pagination'] = $this->pagination->create_links();          $this->load->library('table');         $this->table->set_heading('id','name','e-mail','phone','action');          foreach ($records $record) {              $this->table->add_row($record->id, $record->name, $record->email, $record->phone,                  anchor('crud/viewcrud/'.$record->id,'view').' '.anchor('crud/editcrud/'.$record->id,'edit').' '.anchor('crud/delete/'.$record->id,'delete')                 );         }          $data['table'] = $this->table->generate();          $this->load->view('crudlist',$data);     } 

here model:

    public function count_all()     {         return $this->db->count_all('test');     }     public function get_all_data()     {         return $this->db->get('test')->result();     }     public function get_paged_list($limit, $offset)     {         return $this->db->get('test', $limit, $offset)->result();     } 

here view:

    <div>     <h1>simple crud application</h1>     <div><?php echo $pagination;?></div>     <?php echo form_open('crud/index');?>     <select name="limit" onchange="form.submit()">         <option value="1" <?php if ($limit == 1){ echo "selected='selected'";} ?>>1</option>         <option value="2" <?php if ($limit == 2){ echo "selected='selected'";}?> >2</option>         <option value="4" <?php if ($limit == 4){ echo "selected='selected'";}?> >4</option>     </select>     <?php echo form_close();?>     <div><?php echo $table; ?></div>     <br />     <?php echo anchor('crud/addcrud','add crud'); ?> </div> 

$post not defined, , mean $_post, can used $this->input->post(). replace:

if (!empty($post['limit'])) { 

it should be:

if (!empty($this->input->post('limit'))) { 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -