[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