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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:03:06+00:00 2026-06-12T00:03:06+00:00

Let me explain my issue in detail I have a table called products Products

  • 0

Let me explain my issue in detail

I have a table called products

Products : Name , views , sale_wanted , added_date

I am listing all my products in a view .
I am handling sale wanted through a flag means 0 or 1.
There are some links to sort the listing.

Most Viewed    
Wanted    
For Sale    
New Arrivals    

Now when user clicks all the listing is sorted according to the parameter i am sendig.
I want to use pagination class of Codeigniter.
Here comes some issues.
When i am clicking let suppose Wanted and sending a parameter it lists all the products wanted.

Now i click on a pagination link and the wanted parameter is gone 
and the list becomes without wanted parameter.    

Same goes with the other Anchors.
I have to restrict it so it still has my parameter.
The second problem is that what i see Codeigniter is laking.
I need some links that user can select. Means i want to give the user functionality to select how many products he wants to see in one page.

Let suppose 5 ,10 ,15 ,20    

Choosing the greater number will reduce the number of pages.
And still i want the same functionality.
The important point is that i want to handle all this just in one shot means i dont want to duplicate my code for every anchor.
I need suggestions from expert and any help regarding Pagination library.

  • 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-12T00:03:07+00:00Added an answer on June 12, 2026 at 12:03 am

    I have found a solution for the issue.

    I have made two methods in Codeigniter Pagination library

    Here they are

    Defined two new variables

    var $base_link  =   '';
    var $per_page_link  =   TRUE;
    var $per_page_array =   array();
    

    The user can define both of them while initializing

    $config['per_page_link']    =   TRUE;
    $config['per_page_array']   =   array(5,10,15,20);
    $this->pagination->initialize($config);
    

    Now the methods

    public function create_per_page()
    {
        $CI =& get_instance();
    
        $output =   '';
        $current    =   $CI->uri->segment(3,5);
    
        if($this->per_page_link === TRUE AND count($this->per_page_array) > 1){
    
            foreach($this->per_page_array as $row){
    
                if($current == $row){
                    $output .=  $this->cur_tag_open . $row . $this->cur_tag_close;
                    $output .=  ' ';                   
                }else{
                    $output .=  '<a href="'.$this->base_link.$row.'/1">'.$row.'</a>';
                    $output .=  '&nbsp;';
                }
            }
    
        }
        return  $output;
    }
    

    And the other is create_per_page_links(). I have just copied the code of create_links method in it and modified it. In the start of create_per_page_links() i have added these extra lines.

    $this->per_page =   $CI->uri->segment(3,5);
    $this->uri_segment  =   $CI->uri->segment(4,1); 
    

    However, This will only work with segments on. i haven’t tested it with query string. Also if per_page_link is FALSE both methods will not work.
    Calling create_per_page_links will generate the following

    « First  < 1 2 3 4 5 >  Last »
    

    And create_per_page will generate the following

    5 10 15 20  
    

    And Done

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

Sidebar

Related Questions

Let me explain you my situation. I have a base class called Shape, and
Perhaps a confusing title but let me explain the issue through steps: I have
Hi everyone let me explain this issue: Background: I have two web applications The
I have an issue with the browser [BACK] button. Let me explain. There is
Let me explain my current issue right now: I have a webapp located at
I stumbled onto this problem today, let me explain the issue: I have this
let's see how to explain this issue. I have 4 activities and 1 layout
I could barely find a reasonable title that would explain my issue, let alone
Let me explain best with an example. Say you have node class that can
let me explain my current situation i have a SharePoint site lets say it

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.