我有这段代码:
<?php
$counter = 0;
while ($row = mysql_fetch_array($bim_coupons_price)){?>
<div class="clone">
<div id="start_date_countdown">
<span>No</span>
<input id="start_datetimepicker<?php echo $counter?>" type="text" name="start_date_countdown[]" value="<?php if(isset($_POST['start_date_countdown'][0])){echo $_POST['start_date_countdown'][0];}else{echo $row['start_date_countdown'];}?>"/>
</div>
<div id="end_date_countdown">
<span>Līdz</span>
<input id="end_datetimepicker<?php echo $counter?>" type="text" name="end_date_countdown[]" value="<?php if(isset($_POST['end_date_countdown'][0])){echo $_POST['end_date_countdown'][0];}else{echo $row['end_date_countdown'];}?>"/>
</div>
<div id="price_container">
<span>Cena</span>
<input type="text" id="price_new" name="price_new[]" value="<?php echo $row['price_new']?>"/>
</div>
</div>
<div style="clear:both;"></div>
<?php $counter++; } ?>
问题在于,此while循环将执行3次,并且每次需要将
$_POST['start_date_countdown'][0])
更改为$_POST['start_date_countdown'][1])
,$_POST['start_date_countdown'][2])
等。我该怎么做?
最佳答案
只需将$_POST['INDEX_KEY'][0]
更改为$_POST['INDEX_KEY'][$counter]
。 INDEX_KEY
与start_date_countdown
和end_date_countdown
有关
关于php - WHILE中的PHP数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24436690/