0
我試圖使用CI分頁,問題是,例如:我點擊了分頁數字2,它顯示了我在一頁中的所有7000行。分頁與CI
我的控制器:
public function inicio() { //reporte
$campus=$this -> session -> userdata('campus');
$this->load->library('pagination');
$config['base_url'] = 'http://zeus.xochicalco.edu.mx/saii/sorteos/login/inicio';
$config['total_rows'] = 7000;
$config['per_page'] = 20;
$this->pagination->initialize($config);
$data['boletos'] = $this->model_sorteos->reporte($campus);
$this -> load -> view('/pages/sorteos/template', $data);
}
這是我的模型:
public function reporte($campus,$offset=0){
$x1=0; $x2=0;
$id=1;
$s= new Sorteo();
$s -> where('nombre','Sorteo 9') -> get();
$s->boleto->where('folio >='.$x1.' AND folio <= '.$x2.' ')->get();
$i=0;
$boletos=array();
foreach($s->boleto as $bol){
$b = new Boleto();
$b->where('id',$bol->id)->get();
$b->vendedor->get();
$b->condicion->get();
$b->estado->get();
$b->comprador->get();
$boletos[$i]=array(
'boleto' => $b->folio,
'estado' => $b->estado->nombre,
'condicion' => $b->condicion->nombre,
'vendedor' => $b->vendedor->nombre." ".$b->vendedor->apellido_paterno." ".$b->vendedor->apellido_materno,
'comprador' => $b->comprador->nombre." ".$b->comprador->apellido_paterno." ".$b->comprador->apellido_materno
);
$i++;
} return $boletos; }
的觀點:
<table class="table table-striped table-bordered" style="" >
<tr>
<td>Boleto</td>
<td>Estado</td>
<td>Condicion</td>
<td>Vendedor</td>
<td>Comprador</td>
</tr>
<?php foreach($boletos as $b ){ ?>
<tr>
<td><?php echo $b['boleto']; ?></td>
<td><?php echo $b['estado']; ?></td>
<td><?php echo $b['condicion']; ?></td>
<td><?php echo $b['vendedor']; ?></td>
<td><?php echo $b['comprador']; ?></td>
</tr>
<?php } echo $this->pagination->create_links(); ?> </table> </div>
我在這個新的,一些幫助,好嗎?在此先感謝
什麼在你的視圖文件?您可以嘗試告訴codeigniter偏移量在哪個uri中。例如:$ config ['uri_segment'] = 3; – jah
我添加了視圖,我有一個小問題,我不知道偏移是什麼,以及如何使用或添加它在代碼中。 – Laura
正如你的例子,你想顯示每頁20。因此,前20行顯示在第一頁上,但第2頁上顯示的是20到40,因此第2頁上的偏移量將爲20。在第3頁上,它將爲40,依此類推。但是現在我看到你甚至不能傳遞模型的偏移量,看起來你甚至沒有任何限制。 – jah