title: Parsing multiple checkbox values into php array
body: <p>I have a form which displays stock levels and I want the user to be able to delete multiple products so have provided checkboxes. the code is below: </p>
  
  <pre><code>echo "&lt;form method='get'&gt;
                          &lt;input type='submit' name='removestock' value= 'Remove'&gt;
                          &lt;table class='display' border='0'&gt;
                          &lt;tr&gt;
                          &lt;th&gt;Select&lt;/th&gt;
                          &lt;th&gt;Name&lt;/th&gt;
                          &lt;th&gt;Description&lt;/th&gt;
                          &lt;th&gt;Price (£)&lt;/th&gt;
                          &lt;th&gt;Quantity&lt;/th&gt;
                          &lt;th&gt;Size&lt;/th&gt;
                          &lt;/tr&gt;";
                          echo "&lt;tr&gt;";
                          require ('connection.php');
                          $query = mysql_query("SELECT * FROM items")or die(mysql_error());
                          while($results = mysql_fetch_array($query)){
                              echo "&lt;td&gt; &lt;input type='checkbox' name='item' value='".$results['item_id']."'&gt;&lt;/td&gt;";
                              echo "&lt;td&gt;" . $results['name'] . "&lt;/td&gt;";
                              echo "&lt;td&gt;" . $results['description'] . "&lt;/td&gt;";
                              echo "&lt;td&gt;" . $results['price'] . "&lt;/td&gt;";
                              echo "&lt;td&gt;" . $results['quantity'] . "&lt;/td&gt;";
                              echo "&lt;td&gt;" . $results['size_id'] . "&lt;/td&gt;";
                              echo "&lt;/tr&gt;"; 
                          }
                          echo "&lt;/table&gt;&lt;/form&gt;";
  </code></pre>
  
  <p>And my parsing  code is...</p>
  
  <pre><code>if(isset($_GET['removestock']) === true){
      $errors = array();
      $items = $_GET['item'];
      echo $items;
  }
  </code></pre>
  
  <p>But for some reason it only displays the last item_id selected. Your help will be much appreciated!
  PS. I tried changing the checkbox name to name="items[]" and implemented a foreach loop to parse the data but it still did not work.</p>