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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:41:19+00:00 2026-06-01T23:41:19+00:00

I want to display 2 rows in view page as an output. Again when

  • 0

I want to display 2 rows in view page as an output. Again when i click on to go to the next page it will display 2 next rows and so on ( All together I have 8 rows in
table). But when I run the following code it displays all 8 rows in the view-page along with pagination links. I tried whole day to find the actual reason for not
working it but my problem is still unsolved. I searched for the help on internet with related query but it was of no use. Finalyy I am here with my own words to explain
the problem. I’ve commented almost all the lines in my code. I am loading libraries in autoload for pagination and helper for form and url. I’ll really be thankful if
somebody help me out. Thanks in advance.

   <?php
        class ManageUser extends CI_Controller {  // creating class for the controller
            function index()
            {
                if($this->session->userdata('logged_in'))  // checking users under session if he is already logged in
                {           
                    $this->load->model('admin/user');     // loading model . I am not using Datamapper.
                    $result = $this->user->view_user();   // getting response from the model and storing it to result
                    $total_rows = count($result);         // counting number of rows countered ( its 8 in in my database ) 
                    //echo $total_rows;


                    if($result)
                    {
                        $data['users'] = $result;
                        $config['base_url'] = "http://192.168.0.102/project/index.php/admin/manageUser";  // this is the address where I am pointing the view page url
                        $config['total_rows'] = $total_rows;        // Total numbers of rows assigned to pagination-config
                        $config['per_page'] = '2';                  // I want to display 2 rows in 1 page
                        $config['uri_segment'] = '2';
                        $this->pagination->initialize($config);     // initilizing the pagination-config
                        //$data['pagination'] = $this->pagination->create_links();  
                        //$this->load->vars($data);
                        $this->load->view('admin/manageUser',$data);  // Loading the page
                    }

                    //$this->load->view('admin/manageUser',$data);
                }
                else
                {
                    redirect('admin/login');    // incase of faliured session user will be redirected to the login-page.
                }
            }
        }
        ?>

Following code is from my model named User

 <?php
            Class User extends CI_Model   // extending the model
            {
                function __construct()
                {
                    parent::__construct();
                }

                function view_user()        // function which is loaded from controller
                {

                    $query = $this -> db -> get('users');  //query to fetch all the information from the database
                    return $query->result();        // returning result to the Controller.
                }
            }
        ?>

And finally this is the view page I am using to display the content .

  <!-- This is the view page -->

        <?php if(isset($users)) { ?>     <!-- Checking if user is set -->
             <?php foreach($users as $user) { ?>  <!-- running in a loop to accept all the value from the database and display it row wise -->
                <td><?php echo $user -> us_display_name; ?></td>   <!-- Displaying name -->
                <td><?php echo $user -> us_first_name . " " . $user -> us_last_name; ?></td> <!-- Displaying first name and last name together -->
                <td><?php echo $user -> us_email_id; ?></td>  <!-- Displaying email-ID -->
        <?php } } else { ?>
        <tr>    <td>No records found!</td>
        <?php } ?>
        <?php echo $this->pagination->create_links(); ?>
  • 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-01T23:41:20+00:00Added an answer on June 1, 2026 at 11:41 pm

    You are getting all the users from the Model. That’s not how you do it.
    Your controller should be something like this :

    <?php
        class ManageUser extends CI_Controller {  // creating class for the controller
            function index($offset)
            {
                if($this->session->userdata('logged_in'))  // checking users under session if he is already logged in
                {           
                    $this->load->model('admin/user');     // loading model . I am not using Datamapper.
                    $perpage = 2;
    
                    $result = $this->user->view_user($offset,$perpage);   // getting response from the model and storing it to result
                    $total_rows = $this->db->count_all('users');
    
    
                    if($result)
                    {
                        $data['users'] = $result;
                        $config['base_url'] = "http://192.168.0.102/project/index.php/admin/manageUser";  // this is the address where I am pointing the view page url
                        $config['total_rows'] = $total_rows;        // Total numbers of rows assigned to pagination-config
                        $config['per_page'] = $perpage;                  // I want to display 2 rows in 1 page
                        $config['uri_segment'] = '2';
                        $this->pagination->initialize($config);     // initilizing the pagination-config
                        //$data['pagination'] = $this->pagination->create_links();  
                        //$this->load->vars($data);
                        $this->load->view('admin/manageUser',$data);  // Loading the page
                    }
    
                    //$this->load->view('admin/manageUser',$data);
                }
                else
                {
                    redirect('admin/login');    // incase of faliured session user will be redirected to the login-page.
                }
            }
        }
        ?>
    

    And in the model you need to limit the result

     <?php
            Class User extends CI_Model   // extending the model
            {
                function __construct()
                {
                    parent::__construct();
                }
    
                function view_user($offset,$limit)        // function which is loaded from controller
                {
    
                    $query = $this -> db -> get('users',$perpage,$offset);  //You dont fetch all the data from the database
                    return $query->result();        // returning result to the Controller.
                }
            }
        ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display JQGrid with all column headers but without any data rows
I want to display a ListView in table format. The ListView should have rows
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I want to display a calender view summary report, where on page load I
I want to display >50000 rows in a table. Which is the best control
I have a View that I want to display a UITableView in and animate
I want to select all entries in a MySQL table, and randomly display a
I don't want to display my table view cells until the data has been
I have a custom UITableViewCell subclass, and a table view controller which I want
I have a simple quiz application and I want display a nice timer /

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.