正确的问题,任何人都请帮助我......
我有一个数组
控制器:
$choosen_vendor = $_POST ['choosen_vendor'];
print_r($choosen_vendor); echo "<br/>";
<br/> Array ( [0] => Flash Computer [1] => Toko Jameson's [2] => Flash Computer [3] => Donaldson Filtration Indonesia [4] => Donaldson Filtration Indonesia [5] => )
接下来我做了类似的事情(将用于更新表格)
在ref_no的末尾添加和自动递增,因为它的id_po =&gt;它工作
控制器:
$numven = count(array_count_values(array_filter($choosen_vendor)));
$ar = array_filter(array_unique($choosen_vendor));
$povendor = array_values($ar);
$R = $this -> model_prcsys -> get_max_po ();
$maxpo = $R [0] -> po_id + 1;
$beref = $_POST ['beref'];
for ($i=0; $i < $numven; $i++) {
$update = array (
'pr_id' => $_POST ['prid'] [$i],
'rfq_id' => $_POST ['rfq_id'] [$i],
'vendor_name' => $povendor [$i] ,
'pr_ref_no' => $_POST ['pr_ref'],
'ref_no' => $beref.$maxpo++ ,
'status' => $_POST ['statuspo'] ,
'status_date' => $_POST ['status_date'] ,
);
//$this -> model_prcsys -> create_po ($update);
print_r($update); echo "<br/>";
}
Array ( [pr_id] => 1 [rfq_id] => 1 [vendor_name] => Flash Computer [pr_ref_no] => PR/AI/15/08/1 [ref_no] => PO/SA/15/09/1 [status] => REQ for PO [status_date] => 2015/09/14 )
Array ( [pr_id] => 1 [rfq_id] => 1 [vendor_name] => Toko Jameson's [pr_ref_no] => PR/AI/15/08/1 [ref_no] => PO/SA/15/09/2 [status] => REQ for PO [status_date] => 2015/09/14 )
Array ( [pr_id] => 1 [rfq_id] => 1 [vendor_name] => Donaldson Filtration Indonesia [pr_ref_no] => PR/AI/15/08/1 [ref_no] => PO/SA/15/09/3 [status] => REQ for PO [status_date] => 2015/09/14 )
我会按$_POST
更新项目表,但如果$def_price
或$vendor
为空(0.00),请忽略它(从视图中获取结果) 。
我的观点是这样的:
if ( ($def_price != '0.00') || ($vendor != '') )
{ ?> <input type="hidden" name="prlineid[]" value="<?php echo $row -> pr_line_id ?>" /> <?php }
其他{?&gt;
$code = $_POST ['prlineid'];
$count = count($code);
for ($i=0; $i < $count; $i++) {
$update2 = array (
'status' => $_POST ['statusline'] [$i],
'log_date' => $_POST ['log_date'],
);
$idline = $code [$i];
//$this -> model_prcsys -> update_linesas_reqforpo ($update,$idline);
print_r($idline); echo " ";
print_r($update2); echo "<br/>";
}
1 Array ( [status] => REQ for PO [log_date] => Array ( [0] => 2015/09/14 [1] => 2015/09/14 [2] => 2015/09/14 [3] => 2015/09/14 [4] => 2015/09/14 [5] => 2015/09/14 ) )
<br/>
2 Array ( [status] => REQ for PO [log_date] => Array ( [0] => 2015/09/14 [1] => 2015/09/14 [2] => 2015/09/14 [3] => 2015/09/14 [4] => 2015/09/14 [5] => 2015/09/14 ) )
<br/>
4 Array ( [status] => REQ for PO [log_date] => Array ( [0] => 2015/09/14 [1] => 2015/09/14 [2] => 2015/09/14 [3] => 2015/09/14 [4] => 2015/09/14 [5] => 2015/09/14 ) )
<br/>
6 Array ( [status] => REQ for PO [log_date] => Array ( [0] => 2015/09/14 [1] => 2015/09/14 [2] => 2015/09/14 [3] => 2015/09/14 [4] => 2015/09/14 [5] => 2015/09/14 ) )
<br/>
7 Array ( [status] => REQ for PO [log_date] => Array ( [0] => 2015/09/14 [1] => 2015/09/14 [2] => 2015/09/14 [3] => 2015/09/14 [4] => 2015/09/14 [5] => 2015/09/14 ) )
//IT WORKED, it means it'll update as line_id and ignored the empty cause it not $_POST-ed
我的问题是:在$ update2中,我需要在我的no.2函数中创建的POST PO_ID创建它的每个line_id,换句话说,我需要这个: