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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:28:36+00:00 2026-05-27T03:28:36+00:00

I am trying to display information from database. I have set $config[‘per_page’] to 2,

  • 0

I am trying to display information from database. I have set $config[‘per_page’] to 2, in my view file I can see the information I want but when I click on the next button it doesn’t change anything. The database values remain same and the current page remains the first page too.

Would you please kindly help me figure out the problem?

Thanks in Advance 🙂

Controller:

 function index($id){                   
    $this->load->library('pagination');                                 
    $config['base_url'] = site_url().'Student_fee_status/index/'.$id;

    $this->db->select('*');
    $this->db->from('studentpayment1');
    $this->db->where('studentid', $id); 

    $query = $this->db->get('');
    $numrows=$query->num_rows();                    

    $config['total_rows'] = $numrows;
    $config['per_page'] = 2;
    $config['uri_segment'] = '2'; 
    $config['num_links'] = 20;
    $config['full_tag_open'] = '<div class="pagination" align="center">';
    $config['full_tag_close'] = '</div>';

    $this->pagination->initialize($config);                 
    $this->load->model('Mod_student_fee_status');

    $data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$config['uri_segment']);
    $data['main_content']='view_student_fee_status';

    $this->load->view('includes/template',$data);                   
}   

My Model :

function fee_status($id,$perPage,$uri_segment) { 
    $this->db->select('*');
    $this->db->from('studentpayment1');
    $this->db->where('studentid', $id); 

    $getData = $this->db->get('', $perPage, $uri_segment);

    if($getData->num_rows() > 0)
        return $getData->result_array();
    else
        return null;
}

EDIT

When the page first loads the link looks like this- http://localhost/sundial/Student_fee_status/index/1006/
but when I click on the next page it looks like this- http://localhost/sundial/Student_fee_status/index/1006/2

My View File:

<h1>Payment Status</h1>     
<?php if(count($records) > 0) { ?>
    <table id="table1" class="gtable sortable">
        <thead>
            <tr> 
                <th>S.N</th>
                <th>Invoice ID</th>
                <th>Transaction Description</th>
                <th>Received Date</th>
                <th>Debit</th>
                <th>Credit</th>
                <th>Balance</th>
            </tr>
        </thead>

    <?php $i = $this->uri->segment(2) + 0; foreach ($records as $row){ $i++; ?>
        <tbody>
            <?php
                $mydate= $row['period'];
                $month = date("F",strtotime($mydate));
                $year = date("Y",strtotime($mydate));
            ?>
            <tr>
                <td><?php echo $i; ?>.</td>
                <td><?php echo $row['invoiceid'];?></td>
                <td><a href="<?php echo base_url(); ?>student_fee_status/fee_types/<?php echo $row['paymentid']; ?>" rel="1" class="newWindow" >Total Fee For <?php echo $month ;?>, <?php echo $year ;?>  </a></td>
                <td><?php echo $row['received_date'];?></td>
                <td><?php echo $row['totalamount'];?></td>
                <td><?php echo "0";?></td>
                <td><?php echo $row['totalamount'];?></td>
            </tr>
            <tr>
                <td><?php echo $i; ?>.</td>
                <td><?php echo $row['invoiceid'];?></td>
                <td>Payment Received </td>
                <td><?php echo $row['received_date'];?></td>
                <td><?php echo "0";?></td>
                <td><?php echo $row['amountpaid'];?></td>
                <td>
                    <?php
                        $balance=$row['totalamount']-$row['amountpaid']; 
                        if($balance>0){
                            echo "<font color=\"red\">$balance</font>";
                        }
                        else {
                            echo $balance;
                        }
                    ?>
                </td>
            </tr>
    <?php } ?>
        </tbody>
    </table>
<?php } ?>

<div class="tablefooter clearfix">
    <div class="pagination">
        <?php echo $this->pagination->create_links(); ?> 
    </div>                              
</div>
  • 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-27T03:28:37+00:00Added an answer on May 27, 2026 at 3:28 am

    You are telling the pagination library to use $config['uri_segment'] = '2'; – the second segment of your uri.

    When this is your url: http://localhost/sundial/Student_fee_status/index/1006/ I am guessing this is your base_url: http://localhost/sundial/

    In this case your segments are:

    1. Student_fee_status – your controller
    2. index – the controllers method you are calling
    3. 1006 – the argument you are calling the controllers method with
    4. this should be the argument for pagination

    Try this

    $config['uri_segment'] = '4';

    instead of

    $config['uri_segment'] = '2';

    edit:

    $data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$config['uri_segment']);
    

    I think this line contains another error.

    You pass your model the information which uri_segment is used by the pagination library. That should be 4 now. However, your model uses this value to specify an offset in your query. This means you always put an offset of 4 into your query. But I think what you really want to do is, pass the model the VALUE of the 4th uri_segment.

    I would try this instead:

     $data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$this->uri->segment($config['uri_segment']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp:listbox which I populate from a database. I am however trying
Hello, i'm trying to take detailed information from the database, i create a simple
When trying to display a byte stream from HLDS (Half-Life Dedicated Server) in a
I'm trying to display a series of titles varying from 60 characters to 160
Currently we have a table with a bunch of data from a database which
How do I bind information from my database to a TextView ? The ListView
I have a Sqlite database that has a table consisting of company information (Companies)
I am using a table to display data pulled from two database tables. I
I'm trying to analyse a query execution plan in my Oracle database. I have
I have one problem regarding retriving data from database. I have created one database

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.