<?php
$question = array();
$answer = array();
for($i=1; $i<=5; $i++) {
?>
<div class="container">
<form action="" method="post">
<div class="form-group">
<label>Question No: <?php echo $i; ?></label>
<?php echo "<input type='text' class='form-control' name='qu[$i]'><br/>";
echo "<lable>Answer: </lable>";
echo "<input type='text' class='form-control' name='ans[$i]'><br>";?>
</div>
</form>
</div>
<?php } ?>
<center><button name='submit' class='btn btn-primary btn-home' style="width: 200px;">Submit</button></center>
Here is my code, I want to get all data which is entered in this form. But as a array. After submit the form, this form will collect the values from a loop, so I have to collect values from this loop and convert those to an array.
$numforms? Keep the form tags outside the loop. And check what you get in$_POSTwhen you submit the form.$numis fine, but dont open 5 forms, open one. And does your form have an action or is it empty like here?