我在处理 CI 的分页时遇到了麻烦。为什么视图上的数据没有改变?
看法:
<section class = "home">
<table>
<?php foreach($players as $p): ?>
<tr><td><?php echo $p->uname; ?></td><td><?php echo $p->ufbid; ?></td><td><?php echo $p->uemail; ?></td><td><?php echo $p->umobile; ?></td><td><?php echo $p->points; ?></td><td><?php echo $p->pticks; ?></td></tr>
<?php endforeach; ?>
<tr><?php echo $link; ?></tr>
</table>
控制器:
$perPage = 20;
$pageConf = array(
'base_url' => site_url('home/'),
'total_rows' => $this->home_model->countPlayers(),
'per_page' => $perPage,
'uri_segment' => 2,
//'use_page_numbers' =>TRUE,
);
$this->pagination->initialize($pageConf);
$offset = $this->uri->segment(3) ? $this->uri->segment(3) : 0;
$pData = $this->home_model->displayPlayers($perPage,$offset);
$data = array(
'players'=> $pData,
'content'=> 'home',
'link' => $this->pagination->create_links()
);
$this->load->view('template/template',$data);
我已经在构造函数方法中加载了库。
来自控制器的记录集不会改变。我的uri段3是这样的&per_page=40
。