I have a php form that has a known number of columns (4) and unknown number of rows. In that form I use single selection dropdown, free input text, radio and multiple selection dropdown.
<table>
<tr>
<td><b>Single selection dropdown</b></td>
<td><select name="row[0][column_1]" >
<option></option>
<option>Selection 1</option>
<option>Selection 2</option>
<br />
</select> </td>
<td><b>Free text</b>
<input type="text" name="row[0][column_2]" placeholder="Free text"> </td>
<td><b>Radio</b>
<input type="radio" value="ja" name="row[0][column_3]">Ja
<input type="radio" value="nein" name="row[0][column_3]">Nein
</td>
<td>
<select multiple="multiple" name="row[0][column_4[]]">
<option value="k80">K80</option>
<option value="k50">K50</option>
<option value="hitch">Hitch</option>
<option value="zugpendel">Zugpendel</option>
<option value="Piton-Fix">Piton-Fix</option>
</select>
</td>
</tr>
</table>
At the moment everything work as expected but I cannot get data from multiple selection dropdown.
$row = $_POST['row'];
echo '<table>';
foreach ( $_POST['row'] as $val)
{
echo '<tr>';
echo ' <td>', $val['column_1'], '</td>';
echo ' <td>', $val['column_2'], '</td>';
echo ' <td>', $val['column_3'], '</td>';
if (!empty($val['column_4'])){
foreach((array) $val['column_4'] as $key){
echo ' <td>', $key , '</td>';
}
}
echo '</tr>';
}
echo '</table>';
I guess at some point $val['column_4'] is empty or not an array at all.
Aucun commentaire:
Enregistrer un commentaire