title: Checkbox inside a php foreach loop to delete whatever is checked
body: <p><img src="https://i.stack.imgur.com/VQ4Kt.jpg" alt="enter image description here">  
  
  <pre><code>    echo "&lt;form name='input' action='admin_selecteren_voor_verwijderen.php' method='post'&gt;";
  
      $sql_bestelling= "SELECT * FROM producten";
      foreach($dbh-&gt;query($sql_bestelling) as $row)
          {   
  
              $product_id=$row['product_id'];
              $product_naam=$row['product_naam'];
              $prijs=$row['prijs'];
              $foto=$row['foto'];
  
  
              echo "
  
  
              &lt;br&gt;
              &lt;img src='$foto' height='70' width='50' border='0'&gt;
              &lt;b&gt;$product_naam&lt;/b&gt; &lt;input type='checkbox' name='$product_naam' value='$product_naam'&gt;&lt;/br&gt;
              &lt;/br&gt;&lt;/br&gt;&lt;/br&gt;";
  
              //if (isset($_POST['submit'])){
              //  $sql = "DELETE FROM `producten` WHERE product_naam='$product_naam'";
              //  $query = $dbh-&gt;prepare( $sql );
              //  $result = $query-&gt;execute();
              //}
  
  
              }
  if(!empty($_POST['checkbox'])) {
      foreach($_POST['checkbox'] as $check) {
          echo "check: ", $check; 
      }
  }
  
  
  
  
  
      echo "  
      &lt;input type='submit' value='Delete'&gt;
      &lt;/form&gt;";
  
  
  
  ?&gt;
  </code></pre>
  
  <p>I want to have a list of product in my webshop administrator page. Every product has a checkbox. I want to be able to delete all of the product of the checkboxes are checked. But I don't know how.. The above is what I have so far. The added picture is how it looks on the page.  But the page is a list of product selected from the database with a foreach loop as can be seen in the code. The checkbox also is in the loop. I don't know how to assign every product which is check to a variable and then delete them from the database. Can anyone help me?</p>