Codeigniter分页链接错误

时间:2012-09-26 15:05:02

标签: codeigniter pagination hyperlink

我正在使用codeigniter 2.03及其分页类。它有一个看起来像这样的问题:

1
2
最后一个

这是我在控制器中的代码:

$config['base_url'] = site_url().'/admin/seesubcategory/'; //set the base url for pagination
$config['total_rows'] = $a; //total rows
$config['per_page'] = '12'; //the number of per page for pagination
$config['uri_segment'] = 3; //see from base_url. 3 for this case
$this->pagination->initialize($config); //initialize pagination
$config['num_tag_open'] = '<div id="pagination">';  
$config['num_tag_close'] = '</div>';
$config['prev_link'] = '&lt;';
$config['prev_tag_open'] = '<div>';
$config['prev_tag_close'] = '</div>';

这是我打印链接的代码:

<?php echo $this->pagination->create_links(); ?>

这是我的css:

#pagination a, #pagination strong {
    background: #e3e3e3;
    padding: 4px 7px;
    text-decoration: none;
    border: 1px solid #cac9c9;
    color: #292929;
    font-size: 13px;
}

#pagination strong, #pagination a:hover {
    font-weight: normal;
    background: #cac9c9;
    display: inline-block;
}

1 个答案:

答案 0 :(得分:2)

您的代码应该是这样的

$config['base_url'] = site_url().'/admin/seesubcategory/'; //set the base url for pagination
$config['total_rows'] = $a; //total rows
$config['per_page'] = '12'; //the number of per page for pagination
$config['uri_segment'] = 3; //see from base_url. 3 for this case    
$config['num_tag_open'] = '<div id="pagination">';  
$config['num_tag_close'] = '</div>';
$config['prev_link'] = '&lt;';
$config['prev_tag_open'] = '<div>';
$config['prev_tag_close'] = '</div>';
$this->pagination->initialize($config); //initialize pagination

你需要在所有

的末尾初始化“config”
相关问题