大家好,我正在尝试在 Web 项目中构建分页功能,我将 codeigniter 上的用户指南和 net tuts 上的教程放在这里是链接http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-day-7-pagination/
,但我不断收到这些错误:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$pagination
Filename: views/result_view.php
Line Number: 41
和
Fatal error: Call to a member function create_links() on a non-object in C
无法弄清楚这些错误来自哪里,我该如何解决它们可以有人帮助我这里是我的 cmv:
控制器
<?php
class Result_controller extends CI_Controller{
function getall(){
$this->load->model('result_model');
$data['query'] = $this->result_model->result_getall();
// print_r($data['query']); die();
$this->load->view('result_view', $data);
}
function pagination()
{
$this->load->library('pagination');
$config['base_url'] = 'result_controller/pagination';
$config['total_rows'] = $this->db->get('data')->num_rows();
$config['per_page'] = 5;
$config['num_links'] = 3;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3));
$this->load->view('result_view', $data);
}
看法
<table border="1">
<tr>
<th>Name</th>
<th>Second Name</th>
<th>Phone</th>
<th>Email</th>
<th>Answer</th>
<th>Comment</th>
</tr>
<?php foreach ($query as $row): ?>
<tr>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->second_name; ?></td>
<td><?php echo $row->phone; ?></td>
<td><?php echo $row->email; ?></td>
<td> <?php echo $row->answerA;?>
<?php echo $row->answerB;?>
<?php echo $row->answerC;?></td>
<td><?php echo $row->comment;?><br></td>
</tr>
<?php endforeach; ?>
</table>
<?php echo $this->pagination->create_links(); ?>
模型
<?php
class Result_model extends CI_Model{
function result_getall(){
return $this->db->select('*')
->from('tblanswers, credentials')
->get()
->result_object();
}
}
?>