I have a form where I ask the amount of inputs they need to add information. This is the form
When generating the code to fill in the inputs, I'm going to notice that I have a programming error that I do not know how to solve, since my variables are fixed and I write them over.
<ul>
<?php /*Genera lista de prósitos para cada materia*/
if ($no_proposito1 == 1) {
printf('<li><input type="text" name="propositos1" placeholder="Descripción del proposito"></li>');
} else {
for ($i=1; $i <= $no_proposito1; $i++) {
printf('<li><input type="text" name="propositos1" placeholder="Descripción del proposito"></li>');
}
}
?>
</ul>
I would like to know if someone can support me in how to dynamically generate variables according to the user input, my limit to generate variables are 5.
PS: I am new programming and surely there is a better solution than mine.