Php 显示负值的分页消息

Php 显示负值的分页消息,php,codeigniter,codeigniter-pagination,Php,Codeigniter,Codeigniter Pagination,我正在使用codeigniter,我已经实现了分页以及分页链接旁边的类似于此的消息 Displaying 1 to 11 of 11 但不知怎么的,如果行数较少,它就会显示出来 Displaying -9 to 0 of 8 为什么显示负值?是什么导致了这一次 下面是我为此实现的代码 $data['pagination_message'] = ' Displaying '.((($this->pagination->cur_page-1)*$this->pagination

我正在使用codeigniter,我已经实现了分页以及分页链接旁边的类似于此的消息

Displaying 1 to 11 of 11
但不知怎么的,如果行数较少,它就会显示出来

Displaying -9 to 0 of 8
为什么显示负值?是什么导致了这一次

下面是我为此实现的代码

$data['pagination_message'] = ' Displaying '.((($this->pagination->cur_page-1)*$this->pagination->per_page)+1).' to '.($this->pagination->cur_page*$this->pagination->per_page).' of '.$this->pagination->total_rows;

将此分页用于数据的。这很好用

在控制器中

        $count = $this->Model_Name->count();//get count of your product(s), can pass id too count($id)

        //product pagination
        $config['base_url'] = base_url() .'index.php/product_view/'.;
        $config['total_rows'] = $count;
        $config['per_page'] = 12;
        $config['uri_segment'] = 2;
        $limit = $config['per_page'];


        // pagination style with boostrap. 
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = false;
        $config['last_link'] = false;
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['prev_link'] = '&laquo';
        $config['prev_tag_open'] = '<li class="prev">';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&raquo';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';

        $this->pagination->initialize($config);

        $page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
        $data['links'] = $this->pagination->create_links();

        $data['product'] = $this->Model_Name->get_product($id,$limit,$page);//can pass without $id as well get_product($limit,$page)
视图中(演示视图)


//分页

如果您已经解决了问题,请在本页的答案区域内张贴答案。请不要把答案放在问题里面
  public function get_side_brand_product($limit,$page)
    {
        $query = $this->db->query("SELECT * FROM product WHERE product='$id'  LIMIT $page, $limit");
        $result = $query->result_array();
        return $result;//this return data with objective array
    }
<div class="product_main">
      <div class="product_inner"> 
            <?php
            foreach ($product as $new_product)
            {
                  echo $new_product['field names'];
            }
            ?>
      </div>
      <?php echo $links ?>//pagination
</div>