I have a page where:
- Users register to a page (all data stored in a database)
- They log in with their username
When they have logged in they are supposed to fill a HTML form with 48 selects and 5 input fields. The select boxes looks as the examples below.
<td>Team 1</td>
<select class="combobox" id="m0">
<option>Not chosen</option>
<option>1</option>
<option>X</option>
<option>2</option>
</select>
<td>Team 2</td>
<td>Team 3</td>
<select class="combobox" id="m1">
<option>Not chosen</option>
<option>1</option>
<option>X</option>
<option>2</option>
</select>
<td>Team 4</td>
etc..
What I do today is when the user presses the Done button I call:
onclick="getOptionValues()"
And I loop through all selects and get the values from my input fields and then send out a mail with all the answers, BUT I would like to save all this data to a database instead and connect it to the unique username so when a user login I can populate all the data they have selected before. I have a table in my database called "results" and I have created columns for each answer (54 columns now...), but is there a smarter way to do this and how do you in the code INSERT these to the database? So my question is:
- How do you in a smart way create the database so that you can add 48 checkbox answers and 5 input fields (is it the way that I have done?)
- How do I in the code add them to the database (is it possible to make a loop?)?