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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:35:47+00:00 2026-06-17T13:35:47+00:00

I am new to Codeigniter. This is my first experience in Codeigniter. I have

  • 0

I am new to Codeigniter. This is my first experience in Codeigniter. I have problem in pagination. I have tried lot of codes given on forums and blogs. Lastly I followed a tutorial, link: CodeIgniter from Scratch- Day 16 – Displaying & Sorting Tabular Data – Nettuts+

Here is my code:

user.php

public function index($offset=0)
{
    $limit  =   10;
    $this->load->model('user_model');
    $results                =   $this->user_model->get_all_users($limit,$offset);
    $data['users']          =   $results['rows'];
    $data['num_results']    =   $results['num_rows'];

    $this->load->library('pagination');

    $config =   array();
    $config['base_url']     =   site_url('admin/user');
    $config['total_rows']   =   $data['num_results'];
    $config['per_page']     =   $limit;
    $config['uri_segment']  =   3;
    $this->pagination->initialize($config);
    $date['pagination'] =   $this->pagination->create_links();
    $data['page_title'] =   "List Of Users";
    $this->load->view('admin/users', $data);
}

user_model.php

function get_all_users($limit, $offset)
{
    $q  =   $this->db
                    ->select('user_id,user_email,login_name,phone_num,user_status')
                    ->from('tbl_user')
                    ->limit($limit,$offset);
    $ret['rows']    =   $q->get()->result();

    $q      =   $this->db
                        ->select('COUNT(*) as count', FALSE)
                        ->from('tbl_user');
    $tmp    =   $q->get()->result();
    $ret['num_rows']    =   $tmp[0]->count;
    return $ret;
}

users.php

<?php 
$this->load->view('includes/header');
$this->load->view('includes/menu-admin');
?>
<div id="container">

    <?php if(isset($users)) { ?>
            <p><?php $this->load->view('includes/footer'); ?></p>
        <table id="users_table" class="board">
            <tr>
                <th class="blue-gradient">#</th>
                <th class="blue-gradient">Email Address</th>
                <th class="blue-gradient">Login Name</th>
                <th class="blue-gradient">User Status</th>
                <th class="blue-gradient">Current Status</th>
            </tr>
            <?php $count=1; ?>
        <?php foreach ($users as $user) { ?>
            <tr id="user_<?php echo $user->user_id; ?>" class="darker-on-hover">
                <td><?php echo $count; ?></td>
                <td><?php echo anchor('admin/profile/view/'.$user->user_id,$user->user_email , 'class="view-profile-details"'); ?></td>
                <td><?php echo $user->login_name; ?></td>
                <td><?php echo $user->user_status; ?></td>
                <td>
                    <?php echo anchor('admin/user/edit/'.$user->user_id , '<img src="'.base_url().'images/edit.png" title="Edit User"/>'); ?>
                    <?php echo anchor('admin/user/remove/'.$user->user_id , '<img src="'.base_url().'images/remove.png" title="Remove User"/>', 'class="remove-user-event"'); ?>
                </td>
            </tr>
        <?php $count++; } ?>
        </table>



    <?php } ?>

    <div id="pageNum">
        <?php if(strlen($pagination)): ?>       
            Pages: <?php echo $pagination; ?>
        <?php endif; ?>
    </div>
</div>

Please let me know if I am wrong?

  • 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-17T13:35:48+00:00Added an answer on June 17, 2026 at 1:35 pm

    Set your config like this

    $config['base_url']     =   site_url('admin/user/');
    $config['total_rows']   =   $data['num_results'];
    $config['per_page']     =   $limit;
    $config['uri_segment']  =   3;
    $this->pagination->initialize($config);
    

    Please note / in site_url. It often happens that the url genetrated for pagination is like this

     http://localhost/myapp/index.php/admin/user10
    

    Which is wrong. If you put a slash you will have correct pagination links

    http://localhost/myapp/index.php/admin/user/10
    

    EDITS :

    your controller should look like this

    Class User Extends CI_Controller
    {
        public function __construct()
        {
            parent::__construct();
        }
        public function index($offset=0)
        {
            $limit  =   10;
            $this->load->model('user_model');
            $results                =   $this->user_model->get_all_users($limit,$offset);
            $data['users']          =   $results['rows'];
            $data['num_results']    =   $results['num_rows'];
    
            $this->load->library('pagination');
    
            $config =   array();
            $config['base_url']     =   site_url('user/index');
            $config['total_rows']   =   $data['num_results'];
            $config['per_page']     =   $limit;
            $config['uri_segment']  =   3;
            $this->pagination->initialize($config);
            $date['pagination'] =   $this->pagination->create_links();
            $data['page_title'] =   "List Of Users";
            $this->load->view('admin/users', $data);
        }
    }
    

    See the class name and site_url('class/method') and in your case site_url('user/index')

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

Sidebar

Related Questions

I'm new to codeigniter this is my case: I have a homepage with a
I'm new in codeigniter I have problem I use my OS X Lion, and
Hi i'm new to codeigniter. I have developed this website using CI. http://maxmovies.in/fattto Now
I'm using this datamapper http://datamapper.wanwizard.eu problem is datamapper have validation methods similar with codeigniter
I am planning a new website with codeigniter using wordpress. this site will contain
I am fairly new to PHP and Codeigniter so im sure this will be
I have this function in a Code Igniter model that creates a new video.
I'm new to CodeIgniter and have come into an issue with the insertion of
I'm new in CodeIgniter and read user guide from website. Using pagination class, pagination
i am new with codeigniter.I have written controller,model.view. I want to execute the another

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.