Mysql
 sql >> Datenbank >  >> RDS >> Mysql

PDO fügt ein einfaches Array in die MySQL-Datenbank ein

Einfache Lösung:

$sql = "INSERT INTO questions (`question_name`) VALUES (:question_name)";
// prepare a stamemnt only once
$stmt = $db->prepare($sql);
$stmt->bindParam(':question_name', $question_name);
// iterate over your POST[question_name] array
foreach ($_POST['question_name'] as $question_name) {
    $stmt->execute();
}