CI分页(get)

$count = $this->recruitment->count();


  $pageinfo = $this->pageConfig($count,$myname='search/index');


  $searchpage = abs(intval($this->input->get('searchpage')));


  if($searchpage == 0){$searchpage = 1;}


  $pagestart = ($searchpage-1)*$pageinfo['per_page'];


  $config['searchpage'] = $searchpage;


  $limit = $pageinfo['per_page'];


  $offset = $pagestart;


  $recruitment_info['list'] = $this->recruitment->top($limit,$offset);


  $this->pagination->initialize($pageinfo); // 配置分页


  $pag_links = $this->pagination->create_links();//显示分页





public function pageConfig($count,$myname){


    $arr = explode('&searchpage',$_SERVER['QUERY_STRING']);


    $suffix = '?'.$arr[0];


    $config['base_url'] =  site_url($myname).$suffix;


    $config['total_rows'] = $count;


    $config['per_page'] = 10;


    $config['uri_segment'] = 3;


    $config['page_query_string']= TRUE;


    $config['query_string_segment']= 'searchpage';


 


    $config['first_link'] = '首页';


    $config['last_link'] = '尾页';


    $config['prev_link'] = '上一页';


    $config['next_link'] = '下一页';


    $config['num_links'] = 2;


    $config['full_tag_open'] = ' <div id="pagenav"><ul id="page_nav">';


    $config['full_tag_close'] = '</ul></div>';


    $config['num_tag_open'] = '<li>';


    $config['num_tag_close'] = '</li>';


    $config['cur_tag_open'] = '<li class="nl">';


    $config['cur_tag_close'] = '</li>';


    $config['prev_tag_open'] = '<li>';


    $config['prev_tag_close'] = '</li>';


    $config['next_tag_open'] = '<li>';


    $config['next_tag_close'] = '</li>';


    $config['last_tag_open'] = '<li>';


    $config['last_tag_close'] = '</li>';


    $config['first_tag_open'] = '<li>';


    $config['first_tag_close'] = '</li>';


    return $config;


 } 


你可能感兴趣的:(CI分页(get))