【发布时间】:2015-08-13 05:25:46
【问题描述】:
我的错误:消息:未定义的变量:内容 我认为使用的“内容”变量显然没有定义。但是,当我做 var_dump($result);测试内容..我得到:
array(1) { [0]=> array(7) { ["id"]=> string(3) "148" ["description"]=> 字符串(9)“33”[“日期”]=>字符串(10)“2015-05-30”[“状态”]=> string(1) "1" ["Title"]=> string(2) "33" ["notes"]=> string(9) "33" ["时间"]=> 字符串(8) "07:28:36" } }
我的控制器:
public function edit_news_form() {
$this->load->view('edit_news_form');
$this->load->model('users_model');
$id = $this->uri->segment(3);
$result=$this->users_model->get_id($id);
$data['content']=$result;
}
public function edit(){
$this->load->library('form_validation');
$this->load->model('users_model');
$id = $this->uri->segment(3);
$result=$this->users_model->get_id($id);
$data['content']=$result;
$this->db->trans_start();
$title = $this->input->post('title');
$notes = $this->input->post('notes');
$description = $this->input->post('description');
$date = date('Y-m-d',strtotime($this->input->post('date')));
$status = 1;
$time = date('h:i:s',strtotime($this->input->post('time')));
$data = array(
'Title' => $title,
'description' => $description,
'date'=>$date,
'time'=>$time,
'status' => $status,
'notes' => $notes,
);
$this->users_model->update($id,$data);
$this->db->trans_complete();
}
}
我的模特:
function get_id($id){
$this->db->where('id',$id);
$query = $this->db->get('news');
return $query->result_array();
}
function update($id,$data){
$this->db->where('id', $id);
$this->db->update('news',$data);
}
我的看法:
<label>
<?php echo form_open('resetPasswordController/edit/'.$this->uri->segment(3))?>
<textarea name="description" rel="815"><?php echo $content[0]['description'];?></textarea>
</div>
</label>
【问题讨论】:
标签: php codeigniter variables model-view-controller undefined