Dynamic form in PHP and MySQL

0

I need a dynamic form that operates as follows:

The page should generate Y textboxes according to a Y number that is in the database. My reasoning is as follows:

a. Do the select in the bank to see the number
B. I do a while or a for with this number to display the text
W. I make a string treatment to define the name of the texts (example: text1, text2, text3, etc.)
d. I make the reverse way to save the data in the database.

That's a lot of work. Is there any simpler way?

To contextualize: it is a game of "soccer ball". The administrator registers the games in one day (it can vary the amount of games), and the other day the players users must fill the guesses (in the textboxes).

What can I do to make it simpler?

    
asked by anonymous 20.02.2017 / 18:05

1 answer

0

Create input s with the same attribute name followed by opens and closes square brackets, so in PHP you will have an array ready in $_POST with this information, for example:

<input type="text" name="palpite[]">
<input type="text" name="palpite[]">
<input type="text" name="palpite[]">
...

If you know the exact amount of iterations, mount the fields with for , if you do not know use while .

That is, from its steps from A to D, I only recommend in step C not to treat strings by creating numeric variations of the same name, instead use this pattern to open / close brackets to get an array.

    
20.02.2017 / 18:40