Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter Paginaton下一步按钮不工作_Codeigniter_Codeigniter 2 - Fatal编程技术网

Codeigniter Paginaton下一步按钮不工作

Codeigniter Paginaton下一步按钮不工作,codeigniter,codeigniter-2,Codeigniter,Codeigniter 2,我正在尝试显示数据库中的信息。我已经将$config['per_page']设置为2,在我的视图文件中,我可以看到我想要的信息,但当我单击“下一步”按钮时,它不会更改任何内容。数据库值保持不变,当前页也保持第一页 你能帮我解决这个问题吗 提前感谢:) 控制器: function index($id){ $this->load->library('pagination');

我正在尝试显示数据库中的信息。我已经将$config['per_page']设置为2,在我的视图文件中,我可以看到我想要的信息,但当我单击“下一步”按钮时,它不会更改任何内容。数据库值保持不变,当前页也保持第一页

你能帮我解决这个问题吗

提前感谢:)

控制器:

 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);                   
}   
编辑 当页面首次加载时,链接如下所示- 但当我点击下一页时,它看起来是这样的-

我的视图文件:

<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>
付款状态
S.N
发票ID
事务描述
收到日期
借记
信用
平衡
.
.
收到的款项

您告诉分页库使用
$config['uri_segment']='2'-uri的第二段

当这是您的url时:我猜这是您的基本url:

在这种情况下,您的细分是:

  • 学生费状态-您的管理员
  • index-您正在调用的控制器方法
  • 1006-调用控制器方法时使用的参数
  • 这应该是分页的理由
  • 试试这个

    $config['uri_segment']='4'

    而不是

    $config['uri_segment']='2'

    编辑

    $data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$config['uri_segment']);
    
    我认为这行包含另一个错误

    您向模型传递分页库使用哪个uri_段的信息。现在应该是4了。但是,模型使用此值在查询中指定偏移量。这意味着您总是在查询中输入偏移量4。但我认为您真正想要做的是,将第4个uri_段的值传递给模型

    我会试试这个:

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

    您告诉分页库使用
    $config['uri_segment']='2'-uri的第二段

    当这是您的url时:我猜这是您的基本url:

    在这种情况下,您的细分是:

  • 学生费状态-您的管理员
  • index-您正在调用的控制器方法
  • 1006-调用控制器方法时使用的参数
  • 这应该是分页的理由
  • 试试这个

    $config['uri_segment']='4'

    而不是

    $config['uri_segment']='2'

    编辑

    $data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$config['uri_segment']);
    
    我认为这行包含另一个错误

    您向模型传递分页库使用哪个uri_段的信息。现在应该是4了。但是,模型使用此值在查询中指定偏移量。这意味着您总是在查询中输入偏移量4。但我认为您真正想要做的是,将第4个uri_段的值传递给模型

    我会试试这个:

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

    链接是什么样子的?请也添加视图的相关部分。谢谢你们两位。。查夫和古斯塔夫·伯特伦谢谢你的回复。请检查我上面文章的编辑部分。很抱歉,我们将无法看到您在本地主机上提供的页面。尝试将它们的源代码放在pastebin上,或者将它们公开。我已将代码放在pastebin上。。控制器:型号:视图:谢谢:)链接是什么样子的?请添加视图的相关部分。谢谢你们两位。。查夫和古斯塔夫·伯特伦谢谢你的回复。请检查我上面文章的编辑部分。很抱歉,我们将无法看到您在本地主机上提供的页面。尝试将它们的源代码放在pastebin上,或者将它们公开。我已将代码放在pastebin上。。对于控制器:模型:视图:谢谢:)对不起,walfish3d,我原以为你的建议对我有效,但过了一会儿,我发现“下一步”按钮起作用了,但第一页的数据库值没有改变。你知道我的代码有什么问题吗?提前感谢:)非常非常感谢walfish3d。它的工作方式正是我想要的。我两天来一直在努力解决这个问题。你是个伟大的人……:)很高兴我能帮上忙。我在第一次尝试分页库时基本上遇到了相同的错误:)对不起,walfish3d,我认为你的建议对我有效,但过了一会儿我发现“下一步”按钮有效,但第一页的数据库值没有改变。你知道我的代码有什么问题吗?提前感谢:)非常非常感谢walfish3d。它的工作方式正是我想要的。我两天来一直在努力解决这个问题。你是个伟大的人……:)很高兴我能帮上忙。我在第一次尝试分页库时基本上遇到了相同的错误:)