大家好,我正在尝试将表的状态列contentdetails更新为0。我不知道确切的问题是什么以及我在哪里犯了错误,我无法更新我的状态栏。
这是我的 Controller :
function deleteImage() {
// Pass the $id to the contentDelete() method
$id = $this->input->post('image_id');
if ($id) {
$this->Content_model->imageDelete($id);
$this->session->set_flashdata('success', 'Image deleted.');
redirect('Content');
} else {
$this->session->set_flashdata('error', 'Image Id not captured.');
redirect('Content');
}
}
这是我的模型:
function imageDelete($id) {
$this->db->set('status', 0); //value that used to update column
$this->db->where('id', $id); //which row want to upgrade
$this->db->update('contentdetails'); //table name
}
这是我的观点:
<table class="table table-striped table-bordered" id="dataTable1">
<thead>
<tr>
<th>#</th>
<th>Image path</th>
<th class='text-center'>Delete</th>
</tr>
</thead>
<tbody>
<?php
foreach ($bgimglist as $bgimgs) {
?>
<tr>
<td><?php echo $bgimgs->id; ?></td>
<td><?php echo $bgimgs->details; ?></td>
<td class='text-center'>
<form method="post" action="<?php echo base_url('Content/deleteImage'); ?>">
<input type="text" name="image_id" value="<?php echo $bgimgs->id; ?>">
<button type="submit" onclick="return ConfirmDelete()" class="btn btn-danger btn-xs confirmation" name="login"><i class='fas fa-times'></i></button>
</form>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
谁能帮我解决我做错的地方。
提前致谢。
最佳答案
由于一些误解OP,虽然form_open()
还用上述评论中讨论中可用的代码关闭了表单。因此,任何进一步的表单调用都将转到从未关闭的表单。
添加 </form>
开放形式解决了这个问题。
关于mysql - Codeigniter 中的更新状态列不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51606343/