我的问题是如何更新数据库中更改的值,并用警报通知它在设计页中正确打印了值,但是当我尝试在数据库中更新时...请帮助我修复此错误。我在下面附上了我的错误的屏幕截图
我用于更新的代码:
public function Bill_Update($data)
{
data = $this->input->post();
$count = count($data['Product_Code']);
for($i = 0; $i<$count; $i++){
$entries[] = array(
array(
'billno' =>$this->input->post('billno'),
'Product_Code'=>$data['Product_Code']
[$i],
'Prdtname'=>$data['Prdtname'][$i],
'Qty'=>$data['Qty'][$i],
'rate'=>$data['rate'][$i],
'billdate'=>$newDate,
'amount'=>$data['amount'][$i]
),
);
}
$this->db->update_batch('salesitem',
$entries,'billno');
答案 0 :(得分:0)
尝试
public function Bill_Update($data)
{
$data = $this->input->post();
$count = count($data['Product_Code']);
for($i = 0; $i<$count; $i++){
$entries[] = array(
'billno' =>$this->input->post('billno'),
'Product_Code'=>$data['Product_Code'][$i],
'Prdtname'=>$data['Prdtname'][$i],
'Qty'=>$data['Qty'][$i],
'rate'=>$data['rate'][$i],
'billdate'=>$newDate,
'amount'=>$data['amount'][$i]
);
}
$this->db->update_batch("salesitem", $entries, "billno");
}
答案 1 :(得分:0)
请使用此代码。
<?php
public function Bill_Update($data)
{
$data = $this->input->post();
$count = count($data['Product_Code']);
for($i = 0; $i<$count; $i++){
$entries[] = array(
'billno' => $this->input->post('billno'),
'Product_Code' => $data[$i]['Product_Code'],
'Prdtname' => $data[$i]['Prdtname'],
'Qty' => $data[$i]['Qty'],
'rate' => $data[$i]['rate'],
'billdate' => $newDate,
'amount' => $data[$i]['amount']
);
}
$this->db->update_batch('salesitem', $entries,'billno');
}
我还检查了上面的注释,得到未定义的错误 billno ,能否让我知道salesitem表中“无票据”列的名称,根据我的说法,我们传递的列名称错误,请确保。