Mysql
 sql >> Base de données >  >> RDS >> Mysql

PDO insère un tableau simple dans la base de données MySQL

Solution simple :

$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();
}