title: Joining array values into string in MySQL multiple insert
body: <p>In a form, multiple Checkbox values to be inserted into database:</p>
  
  <p>My Code:</p>
  
  <pre><code>Array: ( [0] =&gt; 1 [1] =&gt; 2 [2] =&gt; 3 [3] =&gt; 4 )
  
  $a = $_POST['id']; // data from form
  $query = "INSERT INTO abc(`x`,`y`,`z`) VALUES " . implode (",","(NULL,$a,'1')");
  
  mysqli_query($dbc,$query);
  </code></pre>
  
  <p>There seems to be a problem with implode function. How do you concat array using implode?</p>
  
  <p>// Expected output</p>
  
  <pre><code>INSERT INTO abc(`x`,`y`,`z`) VALUES (NULL,1,'1'),(NULL,2,'1'),(NULL,3,'1'),(NULL,4,'1'),
  </code></pre>
  
  <p>Column <code>y</code> of table abc needs to loop with $a.</p>