0

In My Controller:

 public function testpages()
   {  
      $config['base_url'] = "http://www.domain.com/index.php/testpages";
      $config['total_rows'] = COUNT($data['names']);
      $config['per_page'] = 1; 
      $this->pagination->initialize($config);
      $data['links'] = $this->pagination->create_links();
      $this->load->view('nameshow',$data);
   }

I want to show the names one by one,but when i click on number links generated by the pagination it shows the url like this:

     http://http://www.domain.com/index.php/testpages/1
     http://http://www.domain.com/index.php/testpages/2

I just want to change the uri segment as:

     http://http://www.domain.com/index.php/testpages/firstnamevalue
     http://http://www.domain.com/index.php/testpages/secondnamevalue

How can i show the url according to my need. with using of pagination, is there any way exist's in codeigniter. if yes then how.?

Rahul Bajaj
  • 375
  • 3
  • 14
  • Can you explain `firstnamevalue`, `secondnamevalue` ? this is the page number, what you want to achieve there ? – Paul Jan 03 '14 at 18:50
  • from the model in which i retrive the records from dataabse.these values existing in the set of array that show's in th above code as $data['names']. – Rahul Bajaj Jan 03 '14 at 18:51
  • `1` `2` `3` `Next >` This is pages not your records from database – Paul Jan 03 '14 at 18:54
  • basically, i set per page reords only 1.just need to change the anchor or the pagno. – Rahul Bajaj Jan 03 '14 at 18:57
  • Pagination is not for that. Read manual http://ellislab.com/codeigniter%20/user-guide/libraries/pagination.html – Paul Jan 03 '14 at 18:59
  • There is full example how to use pagination with list from database to view data : http://www.sitepoint.com/pagination-with-codeigniter/ – Paul Jan 03 '14 at 19:02

1 Answers1

0

You can't change this functionality of the CI pagination plugin, the integer values are page results, or more accurately they are the offset.

Your SQL query consists of limit and offset.

The pagination will show say 10 records (on pg 1), and the link to page #2 would be:

http://http://www.domain.com/index.php/testpages/10

Why? Because your limit is 10 records per page (page 1), so page two is another 10 records and offset is 10 and records start on 11->20 (10), and page #3 will have a link of:

http://http://www.domain.com/index.php/testpages/30

Since you are paginating through number of results, you cannot do "starts with name" and "ends with name", that would have to be custom, and be some sort of range search and not simple limit and offset on result set.

Community
  • 1
  • 1
Jakub
  • 20,418
  • 8
  • 65
  • 92