0

你好我有问题

我想在我的分页codeIgniter中创建按钮,就在最后一页提交表单

这是我的代码:

控制器:

    function index() {
/* pagination config */
        $this->load->library('pagination');
        $config['base_url'] = site_url('dcm/index');
        $config['per_page'] = 6;
        $config['num_link'] = 5;
        $config['next_link'] = 'Next';
        $config['prev_link'] = 'Prev' ;
        $config['total_rows'] = $this->db->get('soal')->num_rows();

/* this my form still have problem but I have different post for this one */
/* if you have any Idea for this please check my Question */
        $data['form_action'] = site_url('dcm/index');     
        $jawab = $this->input->post('jawab');
        $id_soal = $this->input->post('id_soal');
        $this->dcm_model->inputJawab();
        /*  */


/* pagination setting */
        $this->pagination->initialize($config);
        $data['query'] = $this->db->get('soal', $config['per_page'], $this->uri->segment(3));
        $data['link'] = $this->pagination->create_links();
        $this->load->view('dcm/soal', $data);
}

鉴于:

<form action="<?php echo $form_action; ?>">
<?php  foreach($query->result() as $row) { ?>
<?php echo $row->id_soal . '. ' . $row->soal; ?>
<input type="checkbox" checked="checked"  value="<?=$row->id_soal;?>" name="jawab[]" />
<?php } ?>
<?php echo $link; ?>
</form>
<input align="center" type="submit" value="selesai" />
4

1 回答 1

2

您可以使用以下代码检查您是否在最后一页:

if($this->pagination->cur_page >= 
    ceil($this->pagination->total_rows / $this->pagination->per_page))
{
    $isLastPage = true;
}
else
{
    $isLastPage = false;
}

您可以将$isLastPage变量传递给您的视图。

于 2013-08-16T22:38:25.763 回答