Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 {
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
217 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...