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 6852523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:22:52+00:00 2026-05-27T01:22:52+00:00

I am new with codeigniter. Hope can help to solve problem on codeigniter pagination.

  • 0

I am new with codeigniter. Hope can help to solve problem on codeigniter pagination.

  1. i have selected some records from my view and pass to my controller using $_POST.
  2. the controller will use $_POST variable to select records from a model.
  3. then records will be display in the same view with pagination.

step 1-3 is okey, the view display correct info.

  1. when press on the pagination button from my view. This will call the same controller but $_POST info be come blank. So, my view is not displaying with the selected records as needed.

hope can help out.

i have simplied the code as follows:-

controllers:

    $config['total_rows']=$this->invdata_model->getFilterData_numRows();

    $config['base_url']=site_url('site/users_area') ;
    $config['uri_segment'] = '3'; 
    $config['per_page']=18;
    $config['num_links']=4;

    $this->pagination->initialize($config);

    $data['records']=$this->invdata_model->getFilterData_Rows($config['per_page'],$this->uri->segment(3));
    $data['rec_country']=$this->invdata_model->country();

    $this->load->view('includes/header');
    $this->load->view('users_area_view',$data);
    $this->load->view('includes/footer');

models:

    $country = $this->input->post('country') ;


    $this->db->select('stockno, bdlno, country,volton');
    if (isset($country)) { $this->db->where_in('country',$country); }
    $q=$this->db->get('inventory')->num_rows();

    return $q ; 

View

  <?php echo form_open('site/users_area');   
        echo $this->table->generate($records);   
        echo $this->pagination->create_links() ;    ?>

  <div class="gadget">
<?php echo form_submit('submit','Apply','class="button_form"'); ?>      
  </div>

  $gadget['gadget_name']='country'; 
  $gadget['gadget_rec']=$rec_country; 
  $this->load->view('gadget',$gadget);
  </form>

View Gadget

  <div class="gadget">
  <?php

  $gadget_name2=$gadget_name.'[]';

  echo "<ul>";
  foreach ($gadget_rec as $item) {
    echo '<li >';  
    echo '<div id="sectionname">'.$item.'</div>';
    echo '<div id="sectioninput"><input type="checkbox" name="'.$gadget_name2.'" value="'.$item.'"></div>' ;
    echo '-';
    echo "</li>";  
  }

  echo "<ul>";
   ?>
  </div>

Thank you.

  • 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-05-27T01:22:52+00:00Added an answer on May 27, 2026 at 1:22 am

    It sounds like an approach issue. Why are you using POST data to filter your data? The pagination library builds a query string to determine the offset of your database query results. Why can’t you use $_GET instead of $_POST?

    I suppose it would be possible to set your pagination config ‘base_url’ to this:

    $this->load->helper('url');
    $this->load->library('pagination');
    
    $config['base_url'] = current_url().'?'.http_build_query($_POST);
    $config['total_rows'] = 200;
    $config['per_page'] = 20;
    
    $this->pagination->initialize($config);
    
    echo $this->pagination->create_links();
    

    And then in your controller, use $this->input->get_post(), rather than $this->input->post(). Be careful here–it’s rarely safe to pass the full post data directly into a model for processing. It would be better to use CI’s input class to prevent XSS attacks…

    UPDATE:

    To use CI’s input class, rather than $_POST or $_GET directly, I usually keep my form data in a “namespace” of sorts, i.e.:

    <input type="text" name="search[criteria1]" />
    <input type="text" name="search[criteria2]" />
    <input type="text" name="search[criteria3]" />
    

    Then, in your controller:

    ...
    public function some_resource()
    {
        $this->load->model('Some_model');
        $search_criteria = $this->input->get_post('search');
        if ($search_criteria)
        {
            // make sure here to remove any unsupported criteria
            // (or in the model is usually a bit more modular, but
            // it depends on how strictly you follow MVC)
            $results = $this->Some_model->search($search_criteria);
        }
        else
        {
            // If no search criteria were given, return unfiltered results
            $results = $this->Some_model->get_all();
        }
    
        $this->load->view('some_view', array(
            'results'         => $results,
            'pagination_base' => current_url().'?'.http_build_query($search_criteria)
        ));
    }
    ...
    

    Because I specified $this->input->get_post(), it will first check for a query string parameter; if it doesn’t exist, it falls back to post data. This will allow you to use POST in your form, but still pass in the same data through the query string with the pagination class. However, really the form should be using the GET method, as you’re sending these parameters as a query, and not to send something to the server. Just my $.02 on that detail.

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

Sidebar

Related Questions

I have a problem with CodeIgniter .htaccess file and hope that somebody can help
I am new to Codeigniter, and I have trouble with the pagination class. From
I'm new to CodeIgniter, and I need some help. I'd like to implement the
I am new to Codeigniter and PHP.. while doing some operations i have some
i'm new to codeigniter, i have a problem Is it possible to have same
I'm new to CodeIgniter and I hope that my question will have a simple
i have download the new codeigniter 2.0 and put my controller,model and view files
I m new to CodeIgniter so i m facing some problem regarding adding contents
i am new to Codeigniter and I have some trouble in select box validation.
I am still quite new to Codeigniter and have a noob problem I need

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.