我的汽车模型在编辑表单中,用户可以编辑和删除汽车。当用户点击编辑时,他们可以在编辑表单上看到汽车、型号、年份、价格,并进行新的更改并提交。我希望上传的图像也能显示和编辑。我知道 form_input() 不会显示图像。我尝试了一切,但它不会显示在我的编辑表单中。这是我的代码,谢谢!
controller:
public function input($id = 0) {
$this->load->helper('form');
$this->load->helper('html');
$this->load->model('model_users');
/*
if($this->input->post('submit')) {
$this->model_users->entry_insert();
}
$data = $this->books_model->general();
*/
if((int)$id > 0) {
$query = $this->model_users->get($id);
$data['fid']['value'] = $query['id'];
$data['fcar_make']['value'] = $query['car_make'];
$data['fcar_model']['value'] = $query['car_model'];
$data['fcar_year']['value'] = $query['car_year'];
$data['fcar_lease']['value'] = $query['car_lease'];
$data['fcar_payment']['value'] = $query['car_payment'];
$data['fimgpath']['value'] = $query['imgpath'];
}
if($this->session->userdata('is_logged_in')) {
$this->load->view('edit_car',$data);
}
else {
redirect('main/restricted');
}
}
Model:
function get($id) {
$this->db->where(array('id'=>$id));
$query = $this->db->get('cars');
return $query->row_array();
}
view
<tr>
<td>Car Lease:</td>
<td><input type="text" class="textbox" tabindex="6" name = "<?php echo form_input($fcar_lease); ?></td>
<td> </td>
</tr>
<tr>
<td>Car Payment:</td>
<td><input type="text" class="textbox" tabindex="6" name = "<?php echo form_input($fcar_payment); ?></td>
<td> </td>
</tr>
<tr>
<td>Car Image:</td>
<td><input type="file" name=""<?php echo form_input($fimgpath); ?>" size="20" /></td>
<td> </td>
</tr>