I have a table in MySQL to contain user created anti-bot questions. When installing the tables however, I want to insert some default anti-bot questions beforehand. I came up with the following code but I'm not sure exactly how to put it into the correct syntax. Basically, I created two arrays (one for questions and another for answers, in respective and matching order.) and want to cycle through each pair of question and answer using the foreach() or perhaps the while() function.
Here's my code:
$questions = array(
"question1" => "What is 2+6?",
"question2" => "What color is the sky?",
"question3" => "What number is betwee 6 and 8?",
"question4" => "How many letters are there in the English alphabet?",
"question5" => "How many hours are there in a day?",
"question6" => "Are you a human or a bot?"
);
$answers = array(
"answer1" => "8",
"answer2" => "blue",
"answer3" => "7",
"answer4" => "26",
"answer5" => "24",
"answer6" => "human"
);
$x = 0;
foreach ($question[$x]) {
$sql = "INSERT INTO
administrator_instructions
(question, question_naswer)
VALUES
('" . $question[$x] . "','" . $answer[$x] . "')";
$x++;
}