[英]JS ProgressBar update from inside PHP While Loop called by AJAX?
[英]Update Multiple date column in while loop in PHP
僅具有一個日期列的表格需要更新。 但是我無法在表格上填寫其他日期。
html / php表單代碼如下:
<td><form id="form2" name="form2" method="post">
<table width="100%" >
<tr><td colspan="10" align="left"><h3>Container Details</h3>
</td></tr>enter code here
<tr>
<td><table width="100%" >
<tr>
<td><strong>CONTAINER NO</strong></td>
<td><strong>CONTAINER SIZE</strong></td>
<td><strong>CONTAINER CATEGORY</strong></td>
<td><strong>IGM NO.</strong></td>
<td><strong>LINE NO.</strong></td>
<td><strong>BOE NO.</strong></td>
<td><strong>GATE IN DATE</strong></td>
<td><strong>EXPECTED DELIEVRY DATE</strong></td>
<td><strong>GATE OUT DATE</strong></td>
</tr>
<?php
$i=0;
while($r = mysqli_fetch_row($res)){
++$i;
?>
<tr>
<td><input type="hidden" name="vci_no[]" id="vci_no" value="<?php echo @$r['0']; ?>"><?php echo @$r[1]; ?></td>
<td><?php echo @$r[2]; ?></td>
<td><?php echo @$r[3]; ?></td>
<td><?php echo @$r[4]; ?></td>
<td><?php echo @$r[5]; ?></td>
<td><?php echo @$r[6]; ?></td>
<td><?php echo ((date('d-m-Y', strtotime($r['7']))==date('d-m-Y', strtotime('')))?"":date('d-m-Y', strtotime($r[7]))); ?></td>
<td><input type='text' name='gateout_plnd_dt[]' value='<?php echo((date('d-m-Y', strtotime($r[8]))==date('d-m-Y', strtotime('')))?"":date('d-m-Y', strtotime($r[8]))) ?>' class='dt' id="gateout_plnd_dt<? echo $r[0]; ?>"/>
</td><input type="submit" name="save" id="save" value="Update" onClick="return validateUpdateWo()">
更新的代碼:
if(isset($_REQUEST['save'])){
$gateout_plnd_dt = $_REQUEST['gateout_plnd_dt'];
$vci_no = $_REQUEST['vci_no'];
echo sizeof($vci_no);echo sizeof($gateout_plnd_dt);
for($i=0; $i<sizeof($vci_no); $i++){
mysqli_query($con, "update veh_cont_import set gateout_plnd_dt= '".date('Y-m-d', strtotime(urlencode($gateout_plnd_dt[$i])))."'
where vci_no = '".mysqli_real_escape_string($con, $vci_no[$i])."'") or die(mysqli_error($con));
}
我無法在第一個列中選擇任何日期。
我也嘗試過通過PHP為輸入類型傳遞不同的id,但結果相同,如下所示:
id="gateout_plnd_dt<? echo $r[0]; ?>"
完全是其他答案,
命名如下:
然后數組將具有索引,然后您可以使用php檢查不為空的索引
$array = filter_input(INPUT_POST,'gateout_plnd_dt');
foreach($array as $key => $item){
if(strlen($item) > 0){
echo "$key has the value $item" . PHP_EOL;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.