-5
<?php /* for loop starts */ ?>
<div>
<input name="cat[]" type="text" />
</div>
<?php /* for loop ends */ ?>

I want to display each value inside the input box if their POST variable is set.

1 Answer 1

2

try this bro : i have a similar query like this.

<?php
    $j = 0;
    for($i = 1; $i<=8; $i++) {
    ?>
    <tr>
        <td style="width:50% !important;">
            <input type="text" class="form-control" name="cat[]" value="<?php echo isset( $_POST['cat'][$j] ) ? $_POST['cat'][$j] : ''; ?>" />
        </td>
    </tr>
    <?php $j++; } ?>
4
  • Are you sure ` $_POST['PprodName'][$j]` will be available? May 7, 2015 at 10:12
  • @ sgt BOSE no bro. it's my variable name. nut in case of waseem it will be $_POST['cat'].
    – vitally
    May 7, 2015 at 10:13
  • @vitally first i didn't apply the for loop but when i try your code it works fine. thanks.
    – Someone
    May 7, 2015 at 10:20
  • @Waseem Ahmed ur wlcm. but please write proper code from next time.
    – vitally
    May 7, 2015 at 10:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.