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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:11:56+00:00 2026-05-24T21:11:56+00:00

I use of codeigniter and class (library) pagination in it, why after each click

  • 0

I use of codeigniter and class (library) pagination in it, why after each click on pagination in column #, be counted rows from the beginning.

I want like this( p = pagination ):

p1-> #-> 1 2 3

p2-> #-> 4 5 6

p3 -> #-> 7 8 9

p4 #-> 10

EXAMPLE: see example of my problem.
For see full code go to here: FULL CODE

$data['results'] = $this->db->query("SELECT @rownum:=@rownum+1 rownum, t.*
    FROM (
        SELECT *
        FROM hotel_submits
        ORDER BY id desc
        LIMIT $offset, 3    
    ) t,
    (SELECT @rownum:=0) r");

Rownum in top code is the associated with this problem.

You know how to solve this problem?

  • 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-24T21:11:57+00:00Added an answer on May 24, 2026 at 9:11 pm

    Can you retrieve the $offset for the page you are currently on?
    Like if I am on page 1, $offset = 1,
    if I am on page 2, $offset = 4 (1 + (page 2 – 1) * 3)
    if I am on page 3, $offset = 7 (1 + (page 3 – 1) * 3)
    etc.

    If you can’t readily get that at the moment, you can pass it from your controller so your view is aware of the current $offset.
    Then in your code, instead of using $row->rownum, add the value of the current $offset minus 1 since rownum starts 1.

    foreach ($results->result() as $row)
    {
        echo    '<tr><td><input type="checkbox" name="remember_me" value="true" ></td>';
        // echo    '<td>'.$row->rownum.'</td>';
        echo    '<td>'.intval($row->rownum + $offset - 1).'</td>';
        echo    '<td>'.$row->type.'</td>';
        echo    '<td>'.$row->name.'</td>';
        echo    '<td>'.$row->star.' - '.$row->type_star.'</td>';                                
        echo    '<td><span id="'.$row->address.'" class="tooltip">'.$row->address.'</span></td>';
        echo    '<td><span id="'.$row->number_phone.'" class="tooltip">'.$row->number_phone.'</span></td>';
        echo    '<td>'.$row->fax.'</td>';
        echo    '<td>'.$row->site.'</td>';
        echo    '<td>'.$row->email.'</td>';
        echo    '<td>'.$row->date.'</td></tr>';
    }
    

    So on page 2, instead of 1, 2, 3 etc, it should be (1+4-1) 4, (2+4-1) 5, (3+4-1) 6.
    I hope that makes sense.

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

Sidebar

Related Questions

I use of codeigniter and class (library) pagination in it, why not set in
I'm running a LAMP environment with CodeIgniter. I want to be able to use
Is there a way to integrate CodeIgniter with phpBB3? I would like to use
Im trying to use the Zend Frameworks ACL library in my code (in codeigniter)
Just starting to use CodeIgniter, and I'd like to import some of my old
I use CodeIgniter Image Manipulation Class to make a Thumbnail of my images. so
i use of codeigniter Why not work $this->pagination->create_links() in my code? Problem 1: I
I use codeigniter's session class with the option to store session data in a
I am trying to use the trackback library in codeigniter, but I am always
I'm trying to use the CodeIgniter Email Class to write a secure SMTP email;

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.