|
启用了CI的分页,在浏览时很正常,如 127.0.0.1/news/getnews/1 ,在这个分页网页上有链接,是删除新闻的,链接类似于 127.0.0.1/news/delnews/7 ,当点击后,会删除新闻,然后在控制器里重新载入getnews,发现分页$this->uri->segment(3)得到的值为7,而不是1,导致显示不出新闻。
求解决方法,thanks
控制器news里的相关代码为:
function delnews($nid)
{
$this->load->model('News');
$this->News->delete_news($nid);
$this->getnews();
}
function getnews()
{
$this->load->model('News');
$sum=$this->News->get_news_count();
$pagesize=3;
$this->load->library('pagination');
$config['base_url'] = $this->config->item('base_url')."/News/getnews/";
$config['total_rows'] = $sum;
$config['per_page'] = $pagesize;
$config['uri_segment'] = 3;
$config['num_links'] = 3;
$this->pagination->initialize($config);
$news['n']=$this->News->getnews($pagesize,$this->uri->segment(3));
$this->load->view('adminmyweb/News',$news);
} |
|