sql >> Database teknologi >  >> RDS >> Mysql

PDO indsæt et simpelt array i MySQL-databasen

Enkel løsning:

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



  1. En Flask-SQLAlchemy-opdatering skaber en ny rekord i MySQL

  2. XCode, Authentication og NSUserDefaults

  3. Betinget bestilling af

  4. Cloud SQL eller VM Instance til at være vært for MySQL-databasen