title: Deleting multiple rows from database by checkboxes
body: <p>I want to delete multiple rows from database by checkboxes i have working script for "Check All" but when i want delete one or two , nothing happend.</p>
  
  <p><b>JavaScript</b></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  jQuery(function($) {
      $("form input[id='check_all']").click(function() { // triggred check
  
          var inputs = $("form input[type='checkbox']"); // get the checkbox
  
          for(var i = 0; i &lt; inputs.length; i++) { // count input tag in the form
              var type = inputs[i].getAttribute("type"); //  get the type attribute
                  if(type == "checkbox") {
                      if(this.checked) {
                          inputs[i].checked = true; // checked
                      } else {
                          inputs[i].checked = false; // unchecked
                       }
                  }
          }
      });
  
      $("form input[id='submit']").click(function() {  // triggred submit
  
          var count_checked = $("[name='data[]']:checked").length; // count the checked
          if(count_checked == 0) {
              alert("Please select a comment(s) to delete.");
              return false;
          }
          if(count_checked == 1) {
              return confirm("Are you sure you want to delete these comment?");
          } else {
              return confirm("Are you sure you want to delete these comments?");
            }
      });
  }); 
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
      $(document).ready(function(){
          $('.submit').click(function(){
              var checkValues = $('input[name=data[]]:checked').map(function()
              {
                  return $(this).val();
              }).get();
  
              $.ajax({
                  url: 'resources/ajax/ajax_delete_comment.php',
                  type: 'post',
                  data: { data: checkValues },
                  success:function(data){
  
                  }
              });
          });
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><b>HTML/PHP</b></p>
  
  <pre><code>&lt;form method="post" id="form"&gt;
  Check All &lt;input type="checkbox" id="check_all" value=""&gt;
  
  Here im displaying record from database and &lt;input name=\"data[]\" type=\"checkbox\" id=\"data\" value=" . $row['id'] . "&gt;
  
  &lt;input name="submit" class="submit" type="submit" value="Delete" id="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><b>DELETING SCRIPT</b></p>
  
  <pre><code>if(isset($_POST['data'])) {
      $id_array = $_POST['data']; // return array
      $id_count = count($_POST['data']); // count array
  
      for($i=0; $i &lt; $id_count; $i++) {
          $id = $id_array[$i];
          $sql = $db-&gt;query("DELETE FROM comments WHERE `id` = '$id'");
          if ($sql)
              {
                  echo "success";
              }
              else
              {
                  echo "Failed to delete the comment.";
              }
      }}
  </code></pre>
  
  <p>So its work for check all, but when im checking one or two objects, nothing happend, maybe someone could help?</p>