Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9221425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:34:36+00:00 2026-06-18T03:34:36+00:00

i am using codeigniter using pagination but when i select the record per page

  • 0

i am using codeigniter using pagination but when i select the record per page it display the
data but when i click on next page button it will redirect to the 3 page by default we have 25 data field per page so it divide the data on pages by default value.

here is the controller

        function search($page=0)
      {     
        // selecting per page data              
        if ($this->input->post('per_page')!='') {
                 $recordperpage = $this->input->post('per_page');
                 $per =  $this->input->post('per_page');
                 $page = $this->input->post('per_page');
                echo $this->session->userdata('per');
            } 


            else {
                $recordperpage = 25;    
            }
      $keyword = $this->input->post('keyword');

      $result['front'] = $this->search_model->search($keyword,$page,$recordperpage);

    $mypaing['total_rows']= $this->search_model->listing_num('*','tabel_name','flag',1,'keyword',$keyword);
    $mypaing['base_url']    =   base_url()."admin/h_search/search/";
    $mypaing['per_page']    =   $recordperpage;
    $mypaing['uri_segment'] =   4;      
    $this->pagination->initialize($mypaing);
    $result['recordperpage'] = $recordperpage;
    $result['paginglink']   =   $this->pagination->create_links();
    $data['page_heading']   = "Doctor Search Result";
   $data['contents'] = $this->load->view('admin/listing/search',$result,true);  

    $this->load->view('admin/template',$data);
    }`enter code here`

model Model for getting record from search

 function search($keyword,$page,$recordperpage)
{    
    $sql ="SELECT * FROM tabel_name WHERE flag = 1  AND keyword LIKE '%".$keyword."%' 
    LIMIT ".$page.",".$recordperpage."" ;
    $result=$this->db->query($sql);
    return $result; 
} 
function listing_num($select,$from,$where_colum,$where,$where_colum1,$where1)
{
    $this->db->select($select);
    $this->db->from($from);
    $this->db->where($where_colum,$where);
    $this->db->where($where_colum1,$where1);


    $query=$this->db->get();
    return $query->num_rows();
}

View

     <div class="counter">
      <input type="hidden" value="<?=$recordperpage?>" name="rpp_hidden" id="rpp_hidden" />
    <select onchange="this.form.submit();" name="per_page" id="per_page">
    <option value="25" <? if ($recordperpage == 25) {  print 'selected=selected'; }?>  >25</option>
    <option value="50" <? if ($recordperpage == 50) {  print 'selected=selected'; }?> >50</option>
    <option value="75" <? if ($recordperpage == 75) {  print 'selected=selected'; }?> >75</option>
    <option value="100" <? if ($recordperpage == 100) {  print 'selected=selected'; }?> >100</option>
    </select> per page 
  </div>

</div>

when i select the data per post it will redirect to page 1 and shown data from 0 to 50 if i select record per page 50

thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:34:37+00:00Added an answer on June 18, 2026 at 3:34 am

    Where are you setting the offset if it’s not a search? Try adding this above your if statement. If there is no uri segment 4, like when you first load the page, it will set your offset to 0, if there is it will use the segment. Then if it’s a search your if statement will override it:

            $page = ($this->uri->segment(4) ? $this->uri->segment(4) : 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the codeigniter pagination library to page my search results. I am
I'm doing a pagination feature using Codeigniter but I think this applies to PHP/mySQL
I am using Codeigniter pagination library, its working fine. But i am facing problem
Is there anyway to avoid using LIMIT $page,$offset when retrieving rows in codeigniter pagination?
I'm using the Codeigniter pagination, but am encountering an issue. The url changes on
I am using Codeigniter Database Active Record (ODBC Driver). The application run well. But
I am using codeigniter and its pagination class. It works perfectly and it looks
I'm new in CodeIgniter and read user guide from website. Using pagination class, pagination
Using CodeIgniter, how do I access and display text entered into an input field
Using CodeIgniter, I am trying to place several images onto my view page as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.