Welcome Guest, Not a member yet? Register   Sign In
Next error pagination ?
#1

[eluser]Jin Nguyen[/eluser]
I do paging for the search by book title and name of the product publisher. I use the switch to select the type of search.
but when the load again to jump to another page, the variable $ type not defined.
Code:
function search(){
        extract($_POST);    // $type, $search        
        switch($type){            
            case 'Title_book':                                
                $where = array('title like'=>'%'.$search.'%');
                $this->load->library('pagination');    
                $start_row = $this->uri->segment(3);
                $per_page = 10;
                if(trim($start_row)=='')
                {
                    $start_row = 0;
                }
                $things = $this->global_model->get_total_number_record('book',$where);
                $total_row = $things;
                $config['base_url'] = site_url().'/site/search/';
                $config['total_rows'] = $total_row;
                $config['per_page'] = $per_page;                  
                $this->pagination->initialize($config);
                $pagging = $this->pagination->create_links();
                $data=array(
                                'book' => $this->global_model->get_info_type_book($where, $per_page, $start_row),
                                'pagination' => $pagging,
                                'view'=>'site/product/showBook'
                           );
                $this->load->view('site/templates/default/index',$data);                
                break;
            case 'Publishers':
                $where = array('Publisher_Name like'=>'%'.$search.'%');
                $this->load->library('pagination');    
                $start_row = $this->uri->segment(3);
                $per_page = 10;
                if(trim($start_row)=='')
                {
                    $start_row = 0;
                }
                $things = $this->global_model->get_total_number_record('book',$where);
                $total_row = $things;
                $config['base_url'] = site_url().'/site/search/';
                $config['total_rows'] = $total_row;
                $config['per_page'] = $per_page;                  
                $this->pagination->initialize($config);
                $phandoan   = $this->pagination->create_links();                
                 $data = array(
                                'Sach' => $this->global_model->get_info_detail_book($where),
                                'view'=>'site/product/showBook'
                           );                
                $this->load->view('site/templates/default/index',$data);            
                break;
        }
    }
help me ! thanks
#2

[eluser]Jin Nguyen[/eluser]
help me.....................Sad
#3

[eluser]Jin Nguyen[/eluser]
help me..............
#4

[eluser]osci[/eluser]
Maybe defining in function
Code:
function search($search_type = 'Title_book')

change a little your post
if there is no post use $search_type from function failing to your default in case this is not passed too.
Code:
if (isset($type) & ($type <> NULL))
{
   $search_type=$type;
}

use the 4th segment for $start_row

set config for 4th segment and change a little base_url
Code:
$config['uri_segment']=4;
$config['base_url'] = site_url().'/site/search/'.$search_type.'/';


Edit: This topic is not about a bug of course. Maybe that's why you didn't get help in here. You should post this in core or reactor forum.




Theme © iAndrew 2016 - Forum software by © MyBB