点击编辑图标填写表格应该打开,而程序更新
控制器代码
public function update_menus( $id ) {
$data = array(
'menu_title' => $this->input->post('menu_title'),
'filepath' => $this->input->post('filepath'),
'description' => $this->input->post('description'),
'left_content' => $this->input->post('left_content'),
'right_content' => $this->input->post('right_content'),
'url_path' => $this->input->post('url_path'),
'created_date' => date('Y-m-d H:i:s')
);
if ($this->login_database->update($id, $data) == TRUE) {
$this->session->set_flashdata('flash_message', 'updated');
} else {
$this->session->set_flashdata('flash_message', 'not_updated');
}
$this->load->view('update_menus');
$data = array();
$data['menus'] = $this->login_database->get_menus_by_id($id);
$this->load->view('menu_details', $data);
}
型号代码
public function update($id)
{
$data = array(
'menu_title'=> $this->input->post('menu_title'),
'filepath' => $this->input->post('filepath'),
'description' => $this->input->post('description'),
'left_content' => $this->input->post('left_content'),
'right_content' => $this->input->post('right_content'),
'url_path' => $this->input->post('url_path'),
'created_date' =>date('Y-m-d H:i:s')
);
$this->db->where('id',$id);
$menus = $this->db->update('menu_details', $data);
return $menus->result();
}
查看代码
<?php
echo form_open('user_authentication/update_menu_submit');
?><?php foreach ($menus->result() as $row) {
?>
<div class="box-body">
<div class="form-group">
<label for="exampleInputEmail1">Menu Title</label>
<input type="text" name="menu_title" class="form-control" id="exampleInputTitle" placeholder="Enter Menu Title">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Menu Url</label>
<input type="text" name="url_path" class="form-control" id="exampleInputurl" placeholder="Enter File Path">
</div>
<div class="form-group">
<label for="exampleInputFile">Upload Image</label>
<input type="file" name="filepath" id="exampleInputFile">
</div>
<div class="form-group">
<label for="exampleInputDesc">Description</label>
<textarea id="editor4" name="description" rows="10" cols="80" placeholder="Enter Description"></textarea>
</div>
<div class="form-group">
<label for="exampleInputcontl">Left Content</label>
<textarea id="editor5" name="left_content" rows="10" cols="80" placeholder="Enter Left Content"></textarea>
</div>
<div class="form-group">
<label for="exampleInputcontr">Right Content</label>
<textarea id="editor3" name="right_content" rows="10" cols="80" placeholder="Enter Right Content"></textarea>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
<?php
}
echo form_close();
?>
</div>
点击编辑操作后,它应重定向到查看页面,并应打开填充表单,其显示错误,如
致命错误:在布尔值中调用成员函数result() 在线C:\ xampp \ htdocs \ codecms \ application \ models \ login_database.php 模型代码中的205,
答案 0 :(得分:0)
您可以使用以下方法检查生成的查询: $ this- db- last_query();
$data = array(
'menu_title'=> $this->input->post('menu_title'),
'filepath' => $this->input->post('filepath'),
'description' => $this->input->post('description'),
'left_content' => $this->input->post('left_content'),
'right_content' => $this->input->post('right_content'),
'url_path' => $this->input->post('url_path'),
'created_date' =>date('Y-m-d H:i:s')
);
$this->db->where('id',$id);
$menus = $this->db->update('menu_details', $data);
$this->db->last_query();
检查php admin中生成的查询。
返回$ menus-&gt; result();需要吗?