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

  • SEARCH
  • Home
  • 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 7795543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:06:00+00:00 2026-06-01T23:06:00+00:00

I am trying to add search in my lists. I am using codeigniter and

  • 0

I am trying to add search in my lists. I am using codeigniter and pagination for listing. The search is just the database search as a sample id . The search works perfect in the first page of pagination. But when it comes to other pages it does not work.

This is the code for my controller.

  $this->clear_sample_id_catche();
  $out=$this->Mgeneral->listData();
  $per_page = 10;
  $total = $this->Mgeneral->countData();
  $data = $this->Mgeneral->listData($per_page, $this->uri->segment(3));

   $base_url = site_url('general/listData');

   $config['base_url'] = $base_url;
   $config['total_rows'] = $total;
   $config['per_page'] = $per_page;
   $config['uri_segment'] = '3';

  $this->pagination->initialize($config); 
  $data=array('body'=>'list','out'=>$data);

  $this->load->view('template',$data);

I added form to search in my view.
Can any one suggest my what the problem is??
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-01T23:06:02+00:00Added an answer on June 1, 2026 at 11:06 pm

    You must be forgetting to pass the search query for the pagination. Seeing how the page number is the third segment of the query string, I’m guessing that the search form will do a POST action when it gets submitted by the user. After the user submitted the form, of course it will work. Because they just did a POST request, and you fetch the search query from $_POST by using $this->input->post('user_input') or something similar. But then, when they try to navigate to another page by clicking on the page number link (which is a GET request), the search fails because the superglobal $_POST array is empty.

    A solution to solve this problem is to set a session value (I recommend that you use CodeIgniter’s Session Class) based on the user input and instead of using the search query from $_POST, and use the one stored in session instead.

    Another way you can do it, is to make another page for the search result (assuming it is currently in the same page as the form, i.e. in the same controller function). Then make the search form do a GET request to its own controller function which will then encode the search query in base64, and replace the = (equal sign) from the encoded string with a .. After that, redirect the user to the search result page while passing the encoded search query as the third segment in the URL query string (the page number will be the fourth). And in that function replace the . back to = and use base64_decode() to get the search query and pass it to the function that will generate the search result.

    Of course, there are lots of other ways to achieve the same result. Just google it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a search function on a database table using query
I am trying to add full text search capabilities to my RoR app, but
I'm trying to add the selected value from the autocomplete search box to my
Hey there, new to AJAX, JS.. Im trying to add to a Javascript/Ajax search
Trying to add a class object into a List using reflection, but when invoking
Im trying to add an element to a database and then return a new
I am trying to add a search bar with an auto complete in asp.net
I'm trying to add custom fields to an InlineFormset using the following code, but
I'm using a PHP/MySQL connection to add a search suggestions feature to my site.
I am trying to search through a list of dates in my jqgrid using

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.