Mein Code ist wie folgt: Ich versuche, in meine Datenbank mit mehreren Einfügungen gleichzeitig mit einer mysqli_query einfügen, wie gehe ich darüber?Ich habe versucht, eine mysqli_query mit mehreren Einsätzen auszuführen, aber es funktioniert nicht
$sql = "INSERT INTO questions (exam_type, questions, option_a, option_b, option_c, answer)
VALUES ('$q_type', '$q1', '$q1a', '$q1b', '$q1c', '$q1answer');
INSERT INTO questions (exam_type, questions, option_a, option_b, option_c, answer)
VALUES ('$q_type', '$q2', '$q2a', '$q2b', '$q2c', '$q2answer');
INSERT INTO questions (exam_type, questions, option_a, option_b, option_c, answer)
VALUES ('$q_type', '$q3', '$q3a', '$q3b', '$q3c', '$q3answer');
INSERT INTO questions (exam_type, questions, option_a, option_b, option_c, answer)
VALUES ('$q_type', '$q4', '$q4a', '$q4b', '$q4c', '$q4answer');
INSERT INTO questions (exam_type, questions, option_a, option_b, option_c, answer)
VALUES ('$q_type', '$q5', '$q5a', '$q5b', '$q5c', '$q5answer')
";
echo $sql ."<br>";
require "connect.php";
if($results= mysqli_query($con, $sql))
{
echo "saved successfully";
}
Hallo und Willkommen zu Stackoverflow. Nun, die Antwort ist ganz einfach, aber ich werde sie jetzt nicht beantworten. Zunächst bitte ich Sie, Ihre Frage zu bearbeiten. Formatiere es und bringe weitere Informationen mit, damit du lernst, wie man richtig fragt. Nachdem Sie das getan haben, beantworte ich Ihre Frage. Die Lösung ist ziemlich einfach. – Twinfriends
Suche PHP-String-Interpolation. – aristotll
"aber es funktioniert nicht" nichts einfügen? erst einlegen? Welcher Fehler kommt zurück? Spalten der Tabelle? – Cuchu