php - how to route pagination next page in uri->segment(1) eg (example.com/1) -


i have pagination in frontend index page example.com when click page 2 of pagination want load page eg example.com/1.

<?php   function index() {     $e = $this->employer_model->count_jobs_with_employer();     //print_r($e) ;     $config['base_url'] = $this->config->site_url(); //set base url pagination     $config['total_rows'] = $e; //total rows     $config['per_page'] = '10'; //the number of per page pagination     $config['uri_segment'] = 1; //see base_url. 3 case             $config['first_link'] = 'first';     $config['last_link'] = 'last';      $config['full_tag_open'] = '<div class="pagination">';     $config['full_tag_close'] = '</div>';     $this->pagination->initialize($config); //initialize pagination      $page  = ($this->uri->segment(1)) ? $this->uri->segment(1) : 0;      $joblist['listemp'] = $this->employer_model->employerbyjob($config['per_page'], $page);      foreach($joblist['listemp'] $emp)     {         $joblist['jobs'][$emp->u_id] =   $this->employer_model->get_bytbl_col('employer_post_job', 'e_id', $emp->u_id,'dead_line', date('y-m-d'));       }      $c['job_list'] = $this->load->view('front/blocks/employer/job_list', $joblist, true); } ?> 

something should work:

application/config/routes.php:

//default routes: $route['default_controller'] = "yourcontroller"; $route['404_override'] = '';  // custom route: $route['(:num)'] = "yourcontroller/index/$1"; 

application/controllers/yourcontroller.php

function index($page = null) {  } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -