Dynamic form in PHP and Mysql

Asked

Viewed 179 times

0

need a dynamic form that operates as follows:

The page should generate Y textboxes according to a Y number in the bank. My reasoning is this::

a. I select in the bank to see the number
b. I do a while or a for with that number to display the text
c. I do a string processing to define the name of Texts (example: text1, text2, text3, etc.)
d. I do the reverse way to save the data to the database.

It takes a lot of work. There’s some simpler way?

To put it in context: it’s a "football pool" game. The administrator registers the games in one day (the number of games may vary), and the next day the player users must fill in the guesses (in the textboxes).

What can I do to simplify?

  • 2

    What have you done? If you have something done and are in trouble somewhere specific, post the code for part, to be easier to help you

1 answer

0

Create the inputs with the same attribute name followed by opening and closing brackets, this way in PHP you will have an array ready in $_POST with this information, 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 don’t know how to use while.

That is, from your steps from A to D, I only recommend in step C not to handle strings creating numerical variations of the same name, instead use this opening/closing bracket pattern to get an array.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.