计算分页中的行数并显示它?
我在其中使用了 codeigniter
和类 (library) pagination
。
为什么此代码不适用于分页中的计数行
,例如:
现有行:4 ->显示第 1 至 4 条,共 9 条
或
现有行:4 ->显示第 4 至 8 个,共 9 个
或
现有行:1 ->显示第 8 到 9 个,共 9 个
以及
其他
$this->load->library('pagination');
//$this->load->library('Jquery_pagination');
$config['base_url'] = base_url().'admin/accommodation/show';
$config['uri_segment'] = 4;
$config['total_rows'] = $this->db->count_all('hotel_submits');
$config['per_page'] = '4';
//$config['div'] = '#num_count'; /* Here #content is the CSS selector for target DIV */
$config['num_links'] = 10000;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$offset = (int) $offset; // just to make sure nothing funky gets in here
$data['results'] = $this->db->query("SELECT @rownum:=@rownum+1 rownum, t.*
FROM (
SELECT *
FROM hotel_submits
ORDER BY id desc
LIMIT $offset, 4
) t,
(SELECT @rownum:=0) r");
/////////////////////////////////////////////////////////////////
$curr_offset = $this->uri->segment($config['uri_segment']);
$info = 'Showing ' . ( $curr_offset + 1 ) . ' to ' ;
if( ( $curr_offset + $config['per_page'] ) < ( $config['total_rows'] -1 ) )
$info = $curr_offset + $config['per_page'];
else
$info = $config['total_rows'];
$info = ' of ' . $config['total_rows'] . ' | ';
$data['num_count'] = $info;
/////////////////////////////////////////////////////////////////
$this->load->view('admin/accommodation_submit_show', $data);
此代码的输出是:of 9 |
I use of codeigniter
and class (library) pagination
in it.
Why this code don't work for counting rows
in pagination, like:
Existing row: 4 -> Showing 1 to 4 of 9
or
Existing row: 4 -> Showing 4 to 8 of 9
or
Existing row: 1 -> Showing 8 to 9 of 9
and
other
$this->load->library('pagination');
//$this->load->library('Jquery_pagination');
$config['base_url'] = base_url().'admin/accommodation/show';
$config['uri_segment'] = 4;
$config['total_rows'] = $this->db->count_all('hotel_submits');
$config['per_page'] = '4';
//$config['div'] = '#num_count'; /* Here #content is the CSS selector for target DIV */
$config['num_links'] = 10000;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$offset = (int) $offset; // just to make sure nothing funky gets in here
$data['results'] = $this->db->query("SELECT @rownum:=@rownum+1 rownum, t.*
FROM (
SELECT *
FROM hotel_submits
ORDER BY id desc
LIMIT $offset, 4
) t,
(SELECT @rownum:=0) r");
/////////////////////////////////////////////////////////////////
$curr_offset = $this->uri->segment($config['uri_segment']);
$info = 'Showing ' . ( $curr_offset + 1 ) . ' to ' ;
if( ( $curr_offset + $config['per_page'] ) < ( $config['total_rows'] -1 ) )
$info = $curr_offset + $config['per_page'];
else
$info = $config['total_rows'];
$info = ' of ' . $config['total_rows'] . ' | ';
$data['num_count'] = $info;
/////////////////////////////////////////////////////////////////
$this->load->view('admin/accommodation_submit_show', $data);
The output this code is: of 9 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在多个地方:
In multiple places: