I'm having some trouble solving a nested loop. I have a form that sends a series of data to the mysql database. I use a while function and it works correctly. But now I have an checkbox
option for each entry, and that's my problem.
The checkbox should be sent to another table, with the id, the series ID and a checkbox
per row.
But all I can do is make the answer from the first series repeat through the others.
This is what I want:
Lance 1
Checkbox 1
checkbox 3
checkbox 4
Lance 2
checkbox 2
checkbox 3
Lance 3
checkbox 1
checkbox 2
checkbox 3
This is what I get
Lance 1
Checkbox 1
checkbox 3
checkbox 4
Lance 2
Checkbox 1
checkbox 3
checkbox 4
Lance 3
Checkbox 1
checkbox 3
checkbox 4
My loop code so far:
$i=0;
$elements = count($lance);
while ($i < $elementss) {
$query = "INSERT INTO
mapa_bordo_lance
(id_mb, lance, data_lance, lat, lon, anzol, isca, hora_lan, hora_rec, ave_capt, mm_uso)
VALUES
('$id_mb', '$lance[$i]', '$data_lance[$i]', '$lat[$i]', '$lon[$i]', '$anzol[$i]', '$isca[$i]', '$hora_lan[$i]', '$hora_rec[$i]',
'$ave_capt[$i]', '$mm_uso[$i]')";
$result = mysql_query($query, $link);
$y = 0;
$elementss2 = count($checkbox);
while ( $y < $elements2) {
$query = "INSERT INTO mapa_bordo_mm (id_mb, lance, mm)
VALUES ('$id_mb', '$lance[$y]', '$medida_metiga[$y]')";
$result = mysql_query($query, $link);
$y++;
}
$i++;
}