我已经向文章页面添加了一个删除链接,但是当我单击删除时,在 URL 中它说 ..........index.php/news/delet1 它选择了 id 但出现了 404错误。
控制器news.php
public function delete($id){
$id = $this->uri->segment(3);
$data['title'] = 'Delete an item';
if($this->news_model->delete_news($id)){
$this->load->view('templates/header', $data);
$this->load->view('news/success');
$this->load->view('templates/footer');
}
}
视图.php
<p><a href="news/delete<?php echo $news_item['id'] ?>">delete article</a></p>
news_model.php
public function delete_news($id){
$this->db->where('id',$id)->delete('news');
return $this->db->affected_rows();
}
路线
$route['news/delete/(:num)'] = 'news/delete/$1';
帮助将不胜感激。