0

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?

2 Answers 2

2

Just change $_POST['INDEX_KEY'][0] to $_POST['INDEX_KEY'][$counter]. INDEX_KEY pertains to start_date_countdown and end_date_countdown

Sign up to request clarification or add additional context in comments.

3 Comments

why need change end_date_countdown i think it will start_date_countdown?
@RakeshSharma forgot to mention, that I need change both of them.
@Cristian Thank you a lot! I have spent so many time for that, but solution was so easy...
0

Well u are already are using variable $counter.You can make it $_POST['start_date_countdown'][$counter]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.