计算该分页中的行数?
我在其中使用了 codeigniter
和类 (library) pagination
,为什么不在我的示例中设置 column # in pagination 5
和 显示
?
在分页5中显示的是-> 13 到 16 of 16
但分页 5 中的列 #
是 -> 13 14 15。
如果最后分页是一行,则此问题会发生在最后分页之前。
示例: 在此页面中,您将转到分页 5 或 < a href="http://binboy.gigfa.com/admin/accommodation/show/12" rel="nofollow">这是分页 5 的直接链接
function show($offset = 0)
{
$this->admin_model->header();
$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'] = '3';
//$config['div'] = '#num_count'; /* Here #content is the CSS selector for target DIV */
$config['num_links'] = 10000000;
$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, 3
) t,
(SELECT @rownum:=0) r");
$data['offset'] = $offset;
///////////////////////////HERE-START///////////////////////////////
$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;
///////////////////////////HERE-END///////////////////////////////
$this->load->view('admin/accommodation_submit_show', $data);
}
I use of codeigniter
and class (library) pagination
in it, why not set in my example, column # in pagination 5
with showing
?
showing in pagination 5 is-> 13 to 16 of 16
but column #
in pagination 5 is -> 13 14 15.
This problem occur In befor last pagination, if last pagination is a row.
EXAMPLE: in this page you go to pagination 5 or this is direct link to pagination 5
function show($offset = 0)
{
$this->admin_model->header();
$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'] = '3';
//$config['div'] = '#num_count'; /* Here #content is the CSS selector for target DIV */
$config['num_links'] = 10000000;
$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, 3
) t,
(SELECT @rownum:=0) r");
$data['offset'] = $offset;
///////////////////////////HERE-START///////////////////////////////
$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;
///////////////////////////HERE-END///////////////////////////////
$this->load->view('admin/accommodation_submit_show', $data);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
if( ( $curr_offset + $config['per_page'] ) < ( $config['total_rows'] -1 ) )
应该是
if( ( $curr_offset + $config['per_page'] ) <= ( $config ['total_rows'] -1 ) )
if( ( $curr_offset + $config['per_page'] ) < ( $config['total_rows'] -1 ) )
should be
if( ( $curr_offset + $config['per_page'] ) <= ( $config['total_rows'] -1 ) )