我的查看页面:
在这张图片中,我正在获取类似loan no, 的数据partyname,coll.amt使用date(即它显示了我给出时那个特定日期的数据,来自“集合”表)
如果我输入了loan no2的代表 amt,但我没有给loan no1、3。当我按下ok button代表 amt 时,应该在该“集合”表中更新确切的贷款编号和日期。
我的型号代码:
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>
请解决这个问题。
HUX布斯