Situation: I have a static list with check boxes and want to give the user the possibility to choose all or some items of the list. Based on the selection of the user i want to add one or more rows into my SQL table.
My try: I have made a SQL INSERT Query. I have problems to create a loop. With my code it will only insert one row of the last chosen item. Obviously i need to handle my request with a loop. Here my knowledge ends and i need some support. I have nothing found during my search which is fitting to my demands.
(For readability i have removed some information)
My PDO insert query:
// Insert prepared PDO
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$file_titel = trim($_POST['file_titel']);
$audit_id = 2;
// PDO Query um die Daten in die Tabelle zu schreiben
$statement = $pdo->prepare("INSERT INTO file_request(audit_id, file_titel) VALUES (:audit_id, :file_titel)");
$result = $statement->execute(array('audit_id' => $audit_id, 'file_titel' => $file_titel));
if ($result) {
// Wenn der Tabelleneintrag erfolgreich war
$success_msg = "Wurde gesendet";
} else {
// Wenn das nicht geklappt hat
$warning_msg = "Nicht gesendet";
}
} else {
}