title: Delete data with checkbox in a table
body: <p>I display a table on the website after a select option (I use ajax) and get the datas from the database. What I want to do is to insert a checkbox in my table and when it is checked delete the row in the database. I don't want to use a submit button but only the checkbox to delete it. </p>
  
  <p>I'm not really good with ajax and JavaScript. This is the code:</p>
  
  <p>The select :</p>
  
  <pre><code>&lt;p&gt;
              &lt;label for="client"&gt;Veuillez choisir le fournisseur :&lt;/label&gt;&lt;br /&gt;
                 &lt;select name="client" id="client" onchange="showUser(this.value)"&gt;
                      &lt;?php 
                          // echo '&lt;option value=""/&gt;&lt;/option&gt;';
                          while ($donnees = $reponse-&gt;fetch())
                          {               
                              echo '&lt;option value='.$donnees['refCustomer'].'&gt;'.$donnees['legalCompanyName'].' &lt;/option&gt;';                                
                              //$value = $donnees['refCustomer'];                     
                          }
  
  
                          $reponse-&gt;closeCursor();
                      ?&gt;              
                 &lt;/select&gt;
              &lt;/p&gt;
  </code></pre>
  
  <p>The script :</p>
  
  <pre><code>    &lt;script&gt;
      function showUser(str) {
          if (str == "") {
              document.getElementById("txtHint").innerHTML = "";
              return;
          } else { 
              if (window.XMLHttpRequest) {
                  // code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp = new XMLHttpRequest();
              } else {
                  // code for IE6, IE5
                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
              }
              xmlhttp.onreadystatechange = function() {
                  if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                      document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                  }
              }
              xmlhttp.open("GET","getTableBuffer.php?q="+str,true);
              xmlhttp.send();
          }
      }
      &lt;/script&gt;
  </code></pre>
  
  <p>getTableBuffer.php :</p>
  
  <pre><code>    &lt;?php
      $q = intval($_GET['q']);
  
      try
      {
          $bdd = new PDO());
      }
      catch (Exception $e)
      {
              die('Erreur : ' . $e-&gt;getMessage());
      }
  
      $reponse = $bdd-&gt;query('select * from vendor_'.$q.'_offers_ncli_amendments_buffer');
  
  
      echo '&lt;table class="imagetable"&gt;';
      echo '&lt;tr&gt;';
      echo '&lt;th&gt;code&lt;/th&gt;';
      echo '&lt;th&gt;dateAdded&lt;/th&gt;';
      echo '&lt;th&gt;effectiveDate&lt;/th&gt;';
      echo '&lt;th&gt;price&lt;/th&gt;';
      echo '&lt;th&gt;type&lt;/th&gt;';
      echo '&lt;th&gt;destination&lt;/th&gt;';
      echo '&lt;/tr&gt;';
  
      while ($donnees = $reponse-&gt;fetch())
      {       
          echo '&lt;tr&gt;';
          echo '&lt;td&gt;&lt;input type="checkbox" name="code" id="code" value="'.$donnees['code'].'"/&gt;'.$donnees['code'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$donnees['dateAdded'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$donnees['effectiveDate'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$donnees['price'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$donnees['type'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$donnees['destination'].'&lt;/td&gt;';
          echo "&lt;/tr&gt;";           
  
      }
  
      echo "&lt;/table&gt;";
      echo "&lt;/br&gt;";
      echo "&lt;/br&gt;";
      $reponse-&gt;closeCursor();
      ?&gt;
  </code></pre>