我在其中使用codeigniter
和课程(library) pagination
为什么此代码不适用于counting rows
分页,例如:
现有行: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 |
答案 0 :(得分:1)
在多个地方:
$info .=
^