【发布时间】:2019-07-13 09:14:42
【问题描述】:
在这张图片中,我使用date 获取loan no、partyname、coll.amt 之类的数据(即,它显示我给出的特定日期的数据,来自“收集”表)
如果我输入了loan no 2 的rep amt 但我没有给loan no 1、3。当我按下ok button 时,rep amt 应该在那个“collecion”表中更新以获得确切的贷款编号和日期。
我的型号代码:
public function batchinsert($data){
$session_data = $this->session->userdata('logged_in');
$data['username'] = $session_data['repname'];
$LDate = $this->input->post('CDate');
$date = str_replace('/', '-', $LDate);
$newDate = date("Y-m-d", strtotime($date));
$lno = $this->input->post("Sno");
$count = count($data['Sno']);
for($i = 0; $i<$count; $i++){
$entries2[] = array(
'receive_amt'=>$data['ramt'][$i],
);
}
$this->db->where('loanno',$lno);
$this->db->where('collection_date',$newDate);
$this->db->update_batch('collection',$entries2);
// $this->db->insert_batch('test', $entries2);
redirect('Collection_Entry','refresh');
}
我的控制器代码:
public function Collection_Insert(){
$this->load->model('User_model');
$result = $this->User_model->batchinsert($_POST);
}
我的查看页面代码:
<table class="table table-bordered table-striped table-xxs" id="tb3">
<thead>
<tr>
<th>Loan No</th>
<th>Party Name</th>
<th>Coll.Amt</th>
<th>Rep Amt</th>
</tr>
</thead>
<tbody>
<?php
//echo '<pre>';print_r($result2);exit();
if(!empty($query)){
foreach($query as $row){
?>
<tr >
<td ><input style="width:50px" type="text" class="form-control input-xs" name="Sno[]" id="Sno" value="<?=$row['loanno'];?>"></td>
<td> <input style="width:180px" type="text" class="form-control input-xs" name="name[]" id="Amount" value="<?=$row['pname'];?>"></td>
<td ><input style="width:80px" type="text" class="form-control input-xs amt" name="Amount[]" id="Bankname" value="<?=$row['collection_amt'];?>"></td>
<td ><input style="width:80px" type="text" class="form-control input-xs ramt" name="ramt[]" id="Chqamt" value="<?=$row['receive_amt'];?>" autofocus></td>
</tr>
<?php
}
}?>
</tbody>
</table>
请解决这个问题。
【问题讨论】:
-
您能发布您的表单视图吗?还有你从哪里得到这些
$data变量的? -
为了识别您的特定行,您需要为不同的输入提供不同的类。
-
@ArifulIslam 请查看我编辑的代码然后清除它
标签: php codeigniter row