I want to post some inputs which are included in a loop. The problem is that when I click the sumbit button only the last value of the input is posted. Any suggestions?
while ($i <= $number) {
echo '<label class="col-6 col-lg-4 col-form-label">Question ' . $i . '</label><br>
<input class="col-6 col-lg-6 form-control" name="question" id="question" placeholder="Type your question" required/><br>
<div class="form-group row">
<label class="col-6 col-lg-4 col-form-label">Answer 1</label>
<div class="col-6 col-lg-8 d-flex align-items-center">
<input name="correct_answer" type="text" placeholder="Correct answer goes here" required/>
</div>
</div>
<div class="form-group row">
<label class="col-6 col-lg-4 col-form-label">Answer 2</label>
<div class="col-6 col-lg-8 d-flex align-items-center">
<input name="wrong_answer" type="text" placeholder="Type a wrong answer" required/>
</div>
</div>
<div class="form-group row">
<label class="col-6 col-lg-4 col-form-label">Answer 3</label>
<div class="col-6 col-lg-8 d-flex align-items-center">
<input name="wrong_answer2" type="text" placeholder="Type a wrong answer" required/>
</div>
</div><hr>';
$i++;
if(isset($_POST['question'])) {
$question = $_POST['question'];
echo $question;
}
}