计算该分页中的行数?

发布于 2024-11-29 22:31:46 字数 2188 浏览 1 评论 0原文

我在其中使用了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜心 2024-12-06 22:31:46

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 ) )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文