title: How do I insert multiple rows of data into a mysql table using php?
body: <p>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.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>$questions = array(
   "question1"   =&gt;   "What is 2+6?",
   "question2"   =&gt;   "What color is the sky?",
   "question3"   =&gt;   "What number is betwee 6 and 8?",
   "question4"   =&gt;   "How many letters are there in the English alphabet?",
   "question5"   =&gt;   "How many hours are there in a day?",
   "question6"   =&gt;   "Are you a human or a bot?"
  );
  $answers = array(
   "answer1"   =&gt;   "8",
   "answer2"   =&gt;   "blue",
   "answer3"   =&gt;   "7",
   "answer4"   =&gt;   "26",
   "answer5"   =&gt;   "24",
   "answer6"   =&gt;   "human"
  );
  $x = 0;
  foreach ($question[$x]) {
  $sql = "INSERT INTO
   administrator_instructions
    (question, question_naswer)
   VALUES
    ('" . $question[$x] . "','" . $answer[$x] . "')";
  $x++;
  }
  </code></pre>