您好,我真的需要您的帮助。我是Codeigniter的新手,我需要按字母顺序从az实施分页,我不知道从哪里开始..希望您能为我提供帮助。
这是一个外观示例,当然这不是完整的代码,但更像是有关如何完成此操作的指南。
### in your controller
$data['alpha'] = range('a', 'z');
// get the filter value from $_GET array
$alpha_filter = $this->input->get('alpha_filter');
// check if it's actually an alpha; otherwise it's set to null (no filter applied).
if( ! in_array($alpha_filter, $data['alpha'])) $alpha_filter = NULL;
// pass the filter to your model method so it adjusts the results approperiatly
// Note: we're still passing the limit & offset so even with alpha_filter we're still able to paginate the result.
$data['records'] = $this->names_model->get_names($limit, $offset, $alpha_filter);
### in your view
foreach( $alpha as $letter ) {
echo anchor("controller/method?alpha_filter={$letter}", $letter);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句