I have 2 fields, as below, which are checkboxes
:
<tr>
<td>Dizeres Legais:</td>
<td><input type="checkbox" name="export_dizeres[]" value="PORTUGUES"> Português
<input type="checkbox" name="export_dizeres[]" value="INGLES"> Inglês
<input type="checkbox" name="export_dizeres[]" value="ESPANHOL"> Espanhol
<input type="checkbox" name="export_dizeres[]" value="FRANCES"> Francês
<input type="checkbox" name="export_dizeres[]" value="ARABE"> Árabe
<input type="checkbox" name="export_dizeres[]" value="COREANO"> Coreano</td>
</tr>
<tr>
<td>Tabela Nutricional:</td>
<td><input type="checkbox" name="export_tabela[]" value="PORTUGUES"> Português
<input type="checkbox" name="export_tabela[]" value="INGLES"> Inglês
<input type="checkbox" name="export_tabela[]" value="ESPANHOL"> Espanhol
<input type="checkbox" name="export_tabela[]" value="FRANCES"> Francês
<input type="checkbox" name="export_tabela[]" value="ARABE"> Árabe
<input type="checkbox" name="export_tabela[]" value="COREANO"> Coreano</td>
</tr>
Step them into PHP, I can display them as follows:
$listaDizeres = $_POST['export_dizeres'];
foreach ($listaDizeres as $export_dizeres) {
echo $export_dizeres.'<br>';
}
$listaTabela = $_POST['export_tabela'];
foreach ($listaTabela as $export_tabela) {
echo $export_tabela.'<br>';
}
My question is this: Do I need to create a field for every checkbox
in the database, or can I write all the results together in a single field, such as an array? If I subsequently create a change form using Ajax, can I correctly mark the checkboxes
by searching the data in the database?