title: insert array of values into a database using SQL query?
body: <p>I have a PHP array of the column names in my SQL table. I also have an array of the values I want to assign to these columns. How do I put this in an SQL query. At present im writing out each column title like so: </p>
  
  <pre><code>$query = "INSERT INTO `first_page_data`(`a`, `b`, `c`, `d`, `e`, `f`, `g`, `h`) 
  VALUES ('$1','$2','$3','$4','$5','$6','$7','$8')";
  </code></pre>
  
  <p>But there must be a way of just using the arrays?</p>
  
  <p>As an extra, is there a way of defining key/value pairs to keep the two pairs of data together, and then using these to insert into the database? how is this formatted in the SQL query?</p>