title: How to add multiple selection checkboxes to mysql db?
body: <p>I want the user be able to check multiple checkboxes, after which his/hers selection is printed on the html page and add each selection to my Mysql db. Unfortunately I only see the literal string 'Array' being added to my db instead of the selected names. </p>
  
  <p>My script looks as follows :</p>
  
  <pre><code>    &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;checkbox help&lt;/title&gt;
  &lt;/head&gt;
  &lt;?php
  if (isset($_POST['submit'])) {
      $bewoner_naam = $_POST["bewoner_naam"];
      $how_many = count($bewoner_naam);
      echo 'Names chosen: '.$how_many.'&lt;br&gt;&lt;br&gt;';
      if ($how_many&gt;0) {
          echo 'You chose the following names:&lt;br&gt;';
      }
      for ($i=0; $i&lt;$how_many; $i++) {
          echo ($i+1) . '- ' . $bewoner_naam[$i] . '&lt;br&gt;';
      }
          echo "&lt;br&gt;&lt;br&gt;";
  }
  </code></pre>
  
  <p>$bewoner_naam = $_POST['bewoner_naam'];
  echo $bewoner_naam[0]; // Output will be the value of the first selected checkbox
  echo $bewoner_naam[1]; // Output will be the value of the second selected checkbox
  print_r($bewoner_naam); //Output will be an array of values of the selected checkboxes</p>
  
  <pre><code>$con = mysql_connect("localhost","usr","root");
  mysql_select_db("db", $con);
  $sql="INSERT INTO bewoner_contactgegevens (bewoner_naam) VALUES ('$_POST[bewoner_naam]')";
  
  if (!mysql_query($sql,$con))
  
    {
  
    die('Error: ' . mysql_error());
  
    }
  
  echo "1 record added";
  
  
  
  mysql_close($con)
  
  ?&gt;
  
  
  
  &lt;body bgcolor="#ffffff"&gt;
  &lt;form method="post"&gt;
  Choose a name:&lt;br&gt;&lt;br&gt;
  &lt;input type="checkbox" name="bewoner_naam[]" value="kurt"&gt;kurt &lt;br&gt;
  &lt;input type="checkbox" name="bewoner_naam[]" value="ian"&gt;ian &lt;br&gt;
  &lt;input type="checkbox" name="bewoner_naam[]" value="robert"&gt;robert &lt;br&gt;
  &lt;input type="checkbox" name="bewoner_naam[]" value="bruce"&gt;bruce&lt;br&gt;
  &lt;input type="submit" name = "submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;html&gt;
  </code></pre>
  
  <p>Thank you so much with helping me!!!</p>
  
  <p>Kindest regards,</p>
  
  <p>Martin</p>