|
初学CI框架,修改页面总提示我有未定义的ID,不知如何修改,谢谢帮助。下面是我的代码:
控制器代码:
public function upArticle(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->model('News_model','admin');
$config = array(
'title' => $this->input->post('title'),
'time' => $this->input->post('time'),
'content' => $this->input->post('content')
);
$this->admin->set_article($id,$config);
$this->form_validation->set_rules('title', '* 文章标题', 'required|max_length[25]');
$this->form_validation->set_rules('time', '* 发表时间', 'required');
$this->form_validation->set_rules('content', '* 内容', 'required');
if($this->db->affected_rows() > 0)
{
$this->News_model->set_article();
echo "<script>alert('修改文章成功'); window.location.href='/CI2/index.php/News/article'</script>";
}else
{
echo "<script>alert('修改文章失败'); window.location.href='/CI2/index.php/News/article'</scrip";
}
}
模型代码:
public function set_article($id,$config){
$this->load->helper('url');
$this->db->update('news',$config,array('id'=>$id));
}
谢谢帮助。
|
|