我是 CodeIgniter 的新手。如何删除 CodeIgniter 中的特定表格行?我尝试传递 id
变量,但没有任何反应。
这是我的观点:
<tbody>
<?php foreach ($data as $row) { ?>
<tr>
<?php foreach ($row as $cell) { ?>
<td><?php echo $cell; ?></td>
<?php } ?>
<td><?php echo anchor('reports/delete_row',$this->lang->line("common_delete"),array('sale_id'=>'id')); ?></td>
</tr>
<?php } ?>
</tbody>
这是我的 Controller :
public function delete_row()
{
$id = $this->input->get('id');
$this->load->model("reports/summary_sales");
$this->summary_sales->row_delete($id);
}
这是我的模型:
public function row_delete($id){
$this->db->delete('sales', array('id' => 'sale_id'));
}
这是我的 var_dump($cell)
:
string(11) "Rp.-1980.00" string(9) "Rp.500.00"
这是我的var_dump($row)
:
array(5) {
[0]=> string(1) "1"
[1]=> string(10) "2016-01-30"
[2]=> string(8) "Rp.20.00"
[3]=> string(8) "Rp.20.00"
[4]=> string(11) "Rp.-1980.00"
}
array(5) {
[0]=> string(2) "13"
[1]=> string(10) "2016-02-01"
[2]=> string(10) "Rp.3000.00"
[3]=> string(10) "Rp.3000.00"
[4]=> string(9) "Rp.500.00"
}
最佳答案
试试这个。绝对有用
public function row_delete($id)
{
$this->db->where('sale_id',$id);
$this->db->delete('sales');
}
关于php - 如何删除 CodeIgniter 中的特定表格行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35346338/