我正在为我的网站进行分页,我正在显示数据库中的两个表格中的数据我在页面中有分页,但它不会表现得因为它假设表现为不更改页面.目前我在网页上显示了16条记录并设置了$config [‘per_page’] = 1;分页栏最多可达16但不会翻页,所有记录都显示在页面上.任何帮助将不胜感激这里是我的代码:
调节器
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->library('pagination');
$config['base_url'] = 'http://localhost/Surva/index.php/result_controller/getall';
$config['total_rows'] = $this->db->get('tblanswers, credentials')->num_rows();
$config['per_page'] = 1;
$config['num_links'] = 10;
$this->pagination->initialize($config);
$data['records'] = $this->db->get('tblanswers, credentials', $config['per_page'], $this->uri->segment(1, 0))->result_array();
$data['pagination'] = $this->pagination->create_links();
$this->load->view('result_view', $data);
}
}
?>
视图
Name | Second Name | Phone | Answer | Comment | |
---|---|---|---|---|---|
<?php echo $row->name; ?> | <?php echo $row->second_name; ?> | <?php echo $row->phone; ?> | <?php echo $row->email; ?> | <?php echo $row->answerA;?> <?php echo $row->answerB;?> <?php echo $row->answerC;?> | <?php echo $row->comment;?> |
{
echo $pagination;
// echo "
"; var_dump($query);
} ?>
模型
function result_getall(){
return $this->db->select('tblanswers.*,credentials.*')
->from('tblanswers, credentials')
->get()
->result_object();