我工作的分页我的网站,我是从两个表在我的网页数据库中,我有分页上显示的数据,但因为它想表现它剂量不会改变它的页面剂量不会做人。 目前我有16条显示在该网页上,并且已经设置$config['per_page'] = 1;
分页栏上升至16,但剂量不会通过所有的记录都显示在页面上的页面翻转。 任何帮助,将在这里感谢是我的代码:
调节器
<?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->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);
}
}
?>
视图
<div>
<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 if (isset($pagination))
{
echo $pagination;
// echo "<pre>"; var_dump($query);
} ?>
模型
function result_getall(){
return $this->db->select('tblanswers.*,credentials.*')
->from('tblanswers, credentials')
->get()
->result_object();