我应用了分页,但它在一页上显示了整个结果,或者如果我在查询中使用 Limit 应用它,那么它在每一页上显示相同的 20 个结果。
这是控制器文件:
public function hhh($offset = 0 )
{
$sql_query = "select username from valenth_user where banned=1 limit 0,20";
$query = $this->db->query($sql_query)->result_array();
$data["pages"]=$query;
$this->load->library("pagination");
$config = array();
$row = count($pages);
$config['base_url'] = base_url().'/test/hhh/';
$config['total_rows'] = 120;
$config['per_page'] = 20;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
//$data['pages'] = $this-db-get('valenth_user', 10, $offset);
$this-load-library("pagination");
$this-template-load('template/template','onlinee',$data);
//$data['pages'] = $this->db->get($query, 10, $offset);
$query = array_slice($query-result_array(),$rows,$config['per_page']);
}
那就是观点:
<?
$rows = count($pages);
foreach($pages AS $hhh)
{
$user = new user ($hhh['username'],'username');
$hhh['username'] = $user->makeLink();
echo $hhh['username']."<br>";
}
?> <?php echo $this-pagination-create_links(); ?>