Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the use of $this->uri->segment(3) in codeigniter pagination

Tags:

hear is my code

public function viewdeletedrecords() {         if($this->session->userdata('applicant_firstname') == '')     {         redirect('papplicant/login') ;     }     $profile = $this->m_applicant->showdeletedrecods('','');                                                              $total_rows = count($profile) ;     $config['base_url'] =  base_url().'index.php/papplicant/viewdeletedrecords/' ;     $config['per_page'] = '10' ;     $config['full_tag_open'] = '<div>' ;      $config['full_tag_close'] = '</div>' ;      $config['first_link'] = 'First' ;      $config['last_link'] = 'Last' ;      $config['use_page_numbers'] = TRUE ;      $config['prev_link'] = '&lt;' ;      $config['uri_segment'] = 3 ;      $config['num_links'] = 10 ;               $config['cur_tag_open'] = '<b>' ;      $config['cur_tag_close'] = '</b>' ;      $config['total_rows'] = $total_rows ;             $invoicepaginate = $this->m_applicant->showdeletedrecods( $config['per_page'], $this->uri->segment(3)) ;          $this->pagination->initialize($config);           $data4 = array(                                   'data' => $invoicepaginate                                                                                             ) ;      $this->load->view('applicant', $data4);  } 

what is the use of $this->uri->segment(3) in codeigniter

whan I enter $this->uri->segment(3); it works as expected but when I enter $this->uri->segment(4); it stops working

like image 516
nilesh Avatar asked Oct 10 '13 10:10

nilesh


People also ask

What is the use of URI segment 3 in codeigniter?

Segment function allow you to retrieve a specific segment form URI string where n is a segment number. Segments are numbered from left to right. For example,if your URI like. By the above example URI segment function give result by n parameter.

What is URI in codeigniter?

The URI Class provides methods that help you retrieve information from your URI strings. If you use URI routing, you can also retrieve information about the re-routed segments. This class is initialized automatically by the system so there is no need to do it manually.

What is pagination in codeigniter?

The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it. $config['num_links'] = 2; The number of “digit” links you would like before and after the selected page number.

How can get URI segment in core PHP?

Get URI Segments in PHP Use the following code to get URL segments of the current URL. It returns all the segments of the current URL as an array. $uriSegments = explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));


1 Answers

This provides you to retrieve information from your URI strings

$this->uri->segment(n); // n=1 for controller, n=2 for method, etc 

Consider this example:

http://example.com/index.php/controller/action/1stsegment/2ndsegment

it will return

$this->uri->segment(1); // controller $this->uri->segment(2); // action $this->uri->segment(3); // 1stsegment $this->uri->segment(4); // 2ndsegment 
like image 145
Moyed Ansari Avatar answered Sep 17 '22 15:09

Moyed Ansari