Welcome Guest, Not a member yet? Register   Sign In
Pagination and _post variable
#1

[eluser]bianchi[/eluser]
Friends,

How can i hold the _post variable on the pagination..

for example :
when the search happened..

the keyword (_post) = woody

page 2 :
i got :
http://localhost/perfumeshop/perfumes/search/woody/5

but if i clicked page 2,

the url on pagination link lost the woody and will query all of the table...

for example page 3 :
http://localhost/perfumeshop/perfumes/se...0......the keywords "woody" had gone..

How can I keep the keyword ? so my search result can be paginated well...

Thanks
my controller :
Code:
function search(){
            $this->load->helper('html');
            
                 //load pagination class
          $this->load->library('pagination');
          $this->load->library('session');
              
            $this->load->model('perfumes_model');
            
            //$display = $this->input->post('keyword',TRUE);
            
             $display              = $_POST['keyword'];
       //$_SESSION['display']  = $display;
       //$word = $_SESSION['display'];
            /*$displays = array(
                            'keyword' => $this->input->post('keyword'));
                            
            foreach ($displays as $display)
                {
                    //echo $display;
              }
              */
              //echo $word;
            //$this->session->set_userdata('display', $display);  //set value
            //$url = $this->session->userdata('display'); //retrieve value                                                
            //echo $url;
            
            //echo $display;
            
            // Pengaturan konfigurasi untuk pagination
              
              $total_rows = $this->db->query("SELECT COUNT(*) AS total FROM perfumeemporium_general WHERE `description` LIKE '%$display%' ")->row_array();
              
            $config['base_url'] = base_url().'perfumes/search/'.$display;
               //$config['total_rows'] = $this->db->count_all('perfumeemporium_general');
               $config['total_rows'] = $total_rows['total'];
            $config['per_page'] = '5';
            $config['first_link'] = 'First';
            $config['last_link'] = 'Last';
            $config['next_link'] = 'Next';
            $config['prev_link'] = 'Previous';
            $config['uri_segment'] = 4;
            $this->pagination->initialize($config);
            
                
            // Pengaturan konfigurasi untuk pagination
            
            // Query data using model
            //$data['query'] = $this->perfumes_model->perfumes_search_description($display);
            $data['query'] = $this->perfumes_model->perfumes_search_description($display,$this->uri->segment(4,0),$config['per_page']);
            //$this->load->vars($data);
            $this->load->view('perfumes_main',$data);              
                
        }
Model :
Code:
function perfumes_search_description($display,$offset,$num)
      {
          //$this->db->where('name', $name);
            $this->load->database();
            $query = $this->db->query("SELECT * FROM perfumeemporium_general WHERE `description` LIKE '%$display%' ORDER BY `type` LIMIT $offset,$num");
            //$query = $this->db->query("SELECT * FROM perfumeemporium_general WHERE `description` LIKE '%$display%' ORDER BY `type`");
      
            //$query = $this->db->get_where('perfumeemporium_general', array('description' => $display),$num,$offset);
            return $query->result();
            //echo $this->db->last_query();
            //echo $query;
            //$this->output->enable_profiler(true);
      }


Thank you all


Messages In This Thread
Pagination and _post variable - by El Forum - 05-31-2010, 02:26 AM
Pagination and _post variable - by El Forum - 05-31-2010, 02:34 AM
Pagination and _post variable - by El Forum - 05-31-2010, 02:39 AM
Pagination and _post variable - by El Forum - 05-31-2010, 02:40 AM
Pagination and _post variable - by El Forum - 05-31-2010, 02:45 AM
Pagination and _post variable - by El Forum - 05-31-2010, 03:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB