A PHP script is generating the following table panel based on the data from a mysql DB. Each cell of the table contains a checkbox which sets the access to some ‘areas’. The name of my checkboxes are following a certain rule: u[user_id]a[area_name] and I was thinking to get all the $_POST’s which are set and to save them in the data base with their values.
The number of the areas are fixed, but the number of the users varies by days. The table in which I have to save the status of the table is: user_id, current_date, area1, area2, area3, area4, area5, .. area25.
The problem is that I don’t know how to save this table into the database. At this moment I do an insert for each user and I think it has to better solution because this takes too much time.
<form name="foo" method="post" action="saveme.php" />
<table><tr>
<td>name</td><td>area1</td><td>area2</td><td>area3</td><td>area4</td>
</tr>
<tr>
<td>John Smith</td>
<td><input type="checkbox" value="12" name="u1a1" checked /></td>
<td><input type="checkbox" value="13" name="u1a2" /></td>
<td><input type="checkbox" value="16" name="u1a3" /></td>
<td><input type="checkbox" value="21" name="u1a4" checked /></td>
</tr>
</table><input type="submit" value="Save" /> </form>
I think this should do the trick. However, when I see fields like ‘area1, area2, … area25’ – I have a tendency to think there may be a better solution. Perhaps the table should have the fields ‘user_id, current_date, area_id, area’ instead?