0
我似乎无法找到我的代码出了什么问题。我希望能够删除已在表中检查过的记录。Codeigniter ::在复选框中删除多条记录
这是我的看法:
<table id="table" name="table" class="table table-bordered table-condensed table-striped table-primary table-vertical-center checkboxs">
<thead>
<tr>
<th style="width: 1%;" class="uniformjs"><input type="checkbox" /></th>
<th class="center">Item Category</th>
<th class="center" style="width: 90px;">Actions</th>
</tr>
</thead>
<?php foreach($categorycontent->result() as $row): ?>
<tr>
<th style="width: 1%;" class="uniformjs"><input type="checkbox" name="delete[]" value="<?php echo $row->id; ?>"/></th>
<td class="center"><?php echo $row->category_name; ?></td>
<td class="center">
<a href="#" class="btn-action glyphicons pencil btn-success" title="Edit" onClick="popedit('<?php echo $row->id; ?>', '<?php echo base_url(); ?>category/update_category/', 'category')"><i></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<script type="text/javascript">
$(function()
{
popadd("#newcategory", "<?php echo base_url(); ?>category/create_category/", 'category');
popdeletechecked("#deletecategory", "Deleting this record/s will delete all linked information.</br>Are you sure you want to delete it?", "<?php echo base_url(); ?>category/remove_category/");
});
</script>
我的AJAX功能,这是所谓的观点:
function popdeletechecked(buttonid, msg, url)
{
$(buttonid).click(function(){
bootbox.confirm(msg,'No', 'Yes', function(result) {
if(result) {
$.ajax({
url : url,
type : 'POST',
success : function(){
window.location = url;
}
});
}
else {
$.gritter.add({// Doesn't work on page reload
title: 'Deleting Cancelled!'
});
}
});
});
}
我的控制器:
public function remove_category()
{
$checked = $this->input->post('delete');
$this->category_model->delete_category($checked);
redirect('category/read_category');
}
型号:
function delete_category($id)
{
$this->db->where('id', $id);
$this->db->delete('tblitemcategories');
}
没有通过萤火虫返回的错误。我不确定有什么问题,并且我试着根据其他用户的其他问题修改我的代码,这些问题在这里以堆栈的形式回答,但我仍然无法工作。任何帮助深表感谢。我对Codeigniter和PHP相当陌生。提前再次感谢!
请确保所选的ID确实在服务器上发送,请先检查。 – Ghost 2014-11-22 14:46:07
'<?= base_url()?> category/remove_category/= $row-> id?>'and your controller“public function remove_category($ id)” – avenda 2014-11-23 00:35:44
@Ghost我已经做到了。 – Frenkey 2014-11-23 02:42:43