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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:26:49+00:00 2026-06-03T12:26:49+00:00

Im trying to paginate results returned by DB. But when I try to get

  • 0

Im trying to paginate results returned by DB. But when I try to get the offset from URI:

questions/search?content=foobar/4

/4 should be the offset but it is assigned to the $_GET value.

This is the whole method in the controller:

http://pastebin.com/QFJddMDJ

$results = $this->question->search_results_count($content);
$this->load->library('pagination');
$config['total_rows'] = count($results);
$offset = $this->uri->segment(3);
if ($offset == false) $offset = 0;
$config['full_tag_open'] = '<ul class="pages">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li><a  class="active">';
$config['cur_tag_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '<li>';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['first_link'] = '<<';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_link'] = '>>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['per_page'] = 1;
$config['uri_segment'] = 2;
$config['page_query_string'] = TRUE;
$config['use_page_numbers'] = TRUE;
$config['suffix'] = '?content='.$content;
$config['base_url'] = base_url().'questions/search/';
$this->pagination->initialize($config);
  • 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-03T12:26:53+00:00Added an answer on June 3, 2026 at 12:26 pm

    As I’m sure you know, URIs don’t work like that. The query string must be at the end (or before a # hash fragment). This query string:

    questions/search?content=foobar/4
    

    Means $_GET['content'] = 'foobar/4';

    You need to change your pagination URLs to something like this:

    questions/search/4/?content=foobar
    

    The / after the 4 there is also optional.

    You’ll have to remove the query string from your pagination’s $config['base_url'] and instead append it to the links in the view, which sadly involves hacking the pagination class…

    Or try this undocumented feature:

    // After loading the pagination class
    $this->pagination->suffix = '{YOUR QUERY STRING}';
    

    Or better yet, just add $config['suffix'] = '{YOUR QUERY STRING}'; to your config before loading the class. This should automatically add the query string to every link’s href.

    Some adjustments to your config area also needed:

    // Make sure to encode these
    // $config['first_link'] = '<<';
    $config['first_link'] = '&lt;&lt;';
    // $config['last_link'] = '>>';
    $config['last_link'] = '&gt;&gt;';
    
    $offset = $this->uri->segment(3);
    // Default URI segment is 3, and it's what you use above. Remove this.
    // $config['uri_segment'] = 2;
    
    // This should be FALSE (default). Remove it.
    // $config['page_query_string'] = TRUE;
    
    // This should be FALSE (default) if you're
    // using the URI segment as your OFFSET. Remove it.
    // $config['use_page_numbers'] = TRUE;
    
    // Add your query string
    $config['suffix'] = '?content='.$content;
    $config['base_url'] = base_url().'questions/search/';
    $this->pagination->initialize($config);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to paginate a model using kaminari (0.13.0), but I can't get the
I am trying to paginate some data from a model called D filtering results
I have a paginate I am trying to get the index page from an
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
Trying to get a wildcard search to pick up on any text in org_name
I am trying to limit the number of elements returned with mislav's will paginate
I'm trying to make a simple search and return results in a paginated form.
I'm trying to add pagination to my wordpress search results. I was able to
I'm trying to get will paginate to link to my nested route instead of
So I am trying to get my page to paginate after 10 posts on

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.