I have a table with rows that are in the form: ID, Name, First Name, IntA, IntB, IntC, ... The last columns are textfields.
I want to select multiple rows with a Checkbox and send the ID and the recorded integers with POST to another PHP-File.
This is my code-example (with a little bit German in it):
echo "<td><input type='checkbox' name='auswahl[]' value='$daten[0]'></td>";
echo "<td>" . $daten['ID'] . "</td>";
echo "<td><input type='number' name='Schr' value='".$punkte['PktSchr']."'></td>";
echo "<td><input type='number' name='Mdl' value='".$punkte['PktMdl']."'></td>";
So in the other PHP-File I want to SQL for all checked rows like this (in a Loop):
$Eintraege = $_POST['auswahl'];
$Schr = $_POST['Schr'];
$Mdl = $_POST['Mdl'];
foreach ($Eintraege as $i){
$sql = "INSERT INTO aufnahme (IDSchueler, PktSchr, PktMdl) Values ('$i', '$Schr', '$Mdl')";
}
My problem is this: $Eintraege
contains only the IDs of the selected rows (because of value='$daten[0]'
). $Schr
and $Mdl
contains the values of the textfields of the last row (doesn't matter, wich rows are selected).
So I tried to set value='$daten'
and use it lika an array, but then I get an Exception.
I think I have to change value='$daten[0]'
, but don't know how.
Thanks for your help!
Aucun commentaire:
Enregistrer un commentaire