Welcome Guest, Not a member yet? Register   Sign In
pagination with filter results
#1

[eluser]amina[/eluser]
hi, how are you?

I have a dropdown to filter data from a pagination. The pagination works perfect.

how I can link the buttons with different sql querys with sentence where?

The only thing that I did is change the line of code:

Code:
$ query = $this-> edu_model-> get_ficha_list($number_items,_$offset);

I'm copying the function several times and changing the line get_ficha_list but is not the way

My controller.php
Code:
function page() {

  $return = '';

  $this->load->library('pagination');

  $config['base_url']   = site_url('edu/page/');
  $config['total_rows'] = $this->edu_model->get_total_number_news();
  $config['per_page']   = '10';
  $config['num_links']  = '2';
  $config['first_link'] = false;
  $config['last_link']  = false;

  $config['prev_link']   = 'firts';
  $config['prev_tag_open']  = '<div class="list">';
  $config['prev_tag_close'] = '</div>';
  $config['num_tag_open']   = '<div class="list">';
  $config['num_tag_close']  = '</div>';  
  $config['cur_tag_open']   = '<div class="list-selected">';
  $config['cur_tag_close']  = '</div>';  
  $config['next_link']   = 'next';
  $config['next_tag_open']  = '<div class="list">';
  $config['next_tag_close'] = '</div>';

  $config['full_tag_open'] = '<div>';
  $config['full_tag_close'] = '</div>';
                $this->pagination->initialize($config);
                $number_items = $config['per_page'];
  $offset = $this->uri->segment(3);
                
                      
              

  
  $query = $this->edu_model->get_ficha_list($number_items, $offset);
  foreach ($query->result() as $row){
   $data = array(
    'id'    => $row->id,
    'title'    => $row->title,
    'descripcion' =>  row->descripcion
    
   );
   $return .= ($this->get_ficha_edu_dis($data));
  }

  $return .= '<p>'.$this->pagination->create_links().'</p>';
                
  if(0 > $this->uri->segment(3))
   return $return;
  else
   return $this->index($return);
}

my model.php
Code:
public function get_total_number_news(){
  return $this->db->count_all('edu');
}

/**
  *
  * Get Ficha List  */
public function get_ficha_list($number_items,$offset) {
  $this->db->select('id, title ,descripcion, filtro');
                $this->db->where("filtro","notice");
  return $this->db->get('edu', $number_items,$offset);
}
      
      public function get_ficha_list_gestion($number_items,$offset) {
  $this->db->select('id, title ,descripcion, filtro');
                $this->db->where("filtro","gestion");
  return $this->db->get('edu', $number_items,$offset);
}

my view
Code:
<a href="edu.html" title="filter">Filter</a>
<ul> <li>&lt;?= anchor('/edu/page','Gestion') ?&gt;</li>
<li>&lt;?= anchor('/edu/page','notice') ?&gt;</li>
</ul>

Anyone have any other idea!
Thanks




Theme © iAndrew 2016 - Forum software by © MyBB