title: How to Insert Multiple Checkbox Values into a Database
body: <p>I've been working on this and searching the Web and coming up empty for the better part of two days.  With a lot of sweat, I can insert one checkboxed value into a DB; however, if I check more boxes, it will still only insert one value. </p>
  
  <p>Here is my code I'm using on input user page (with form tags excluded):</p>
  
  <pre><code>  &lt;input type="checkbox" name="skills[]" value="1"&gt; ActionScript&lt;br /&gt;
    &lt;input type="checkbox" name="skills[]" value="2"&gt; AppleScript &lt;br /&gt;
  </code></pre>
  
  <p>Now I'm grabbing two session variables to make link the selected skill to the user who is logged on:</p>
  
  <pre><code>  $skills = $_POST['skills'];
    $id = $_SESSION['Ind_ID'];
  </code></pre>
  
  <p><strong>Here is the code that there is some small error in:</strong></p>
  
  <pre><code>for ($i=0; $i&lt;sizeof($skills);$i++) {
      // echo $skills[$i];
      $query= "INSERT INTO individual_skills(Skills_ID,Ind_ID) VALUES (" .$skills[$i]. ",
              ".$_SESSION['Ind_ID'].")";
   }
  </code></pre>
  
  <p>With my echo $skills[$i] I can see that I am looping and can display as many user inputs to the screen; so, that is the good news.  </p>
  
  <p>The <strong>issue</strong> is I can't get it to <strong>insert more than one value into a DB</strong>.  I can do one value at a time; but, no more than one.  </p>
  
  <p>It seems my query is pretty close.  It works perfect if I choose to select only one checkbox; however, if I select more than one, it only inputs the last value (so, if I have 10 values selected, it will insert the last value into the DB).</p>
  
  <p>Any help, much appreciated.</p>
  
  <p>I'm using PHP and MySQLi</p>
  
  <p><strong>UPDATED BASED ON FEEDBACK FOR LOOP</strong>
  Here is the updated loop.  I have the query outside the loop, and now trying to APPEND to my initial query.  Error says something is wrong with the syntax of the query.</p>
  
  <pre><code>$query= "INSERT INTO individual_skills(Skills_ID,Ind_ID) VALUES (" .$skills[$i]. ",
                                                          ".$_SESSION['Ind_ID'].")";
  
    for ($i=0; $i&lt;sizeof($skills);$i++) {
    //echo $skills[$i];
    $query.= " VALUES (" .$skills[$i]. ",".$_SESSION['Ind_ID'].")";
    }
  </code></pre>