Reputation: 362
I have this piece of code:
<?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++; } ?>
Problem is there that this while loop will executes 3 times and I need to change $_POST['start_date_countdown'][0])
every time to $_POST['start_date_countdown'][1])
, $_POST['start_date_countdown'][2])
etc...
How I can do that?
Upvotes: 0
Views: 68
Reputation: 2097
Just change $_POST['INDEX_KEY'][0]
to $_POST['INDEX_KEY'][$counter]
. INDEX_KEY
pertains to start_date_countdown
and end_date_countdown
Upvotes: 2
Reputation: 549
Well u are already are using variable $counter.You can make it $_POST['start_date_countdown'][$counter]
Upvotes: 0