title: Delete Data from MySQL Using PHP & AJAX
body: <p>I have a one form and which have multiple form fields with remove button.All data is coming from DB.now when i am click on remove button i want to remove this data from DB using ajax.</p>
  
  <p><strong>PHP Code:-</strong></p>
  
  <pre><code>&lt;?php 
      for($i=0;$i&lt;$hdntotal;$i++)
      { 
  ?&gt;
             &lt;div class="expform" id="&lt;?=$i;?&gt;"&gt;
             &lt;label class="explabel"&gt;Expert Name: &lt;/label&gt;&lt;input type="text" id="txtexpname" name="txtexpname[]" class="expfield" placeholder="Enter name of expert" value="&lt;?=$expert_name[$i]; ?&gt;"/&gt;
             &lt;div class="clearboth"&gt;&lt;/div&gt;
             &lt;label class="explabel"&gt;Link of the expert work: &lt;/label&gt;&lt;input type="text" id="txtexplink" name="txtexplink[]" class="expfield" placeholder="Enter link of expert work" value="&lt;?=$expert_user_links[$i];?&gt;"/&gt;
             &lt;div class="clearboth"&gt;&lt;/div&gt;
             &lt;label class="explabel"&gt;Title of the review: &lt;/label&gt;&lt;input type="text" id="txtreviewtitle" name="txtreviewtitle[]" class="expfield" placeholder="Enter title of review" value="&lt;?=$expert_title[$i];?&gt;"/&gt;
             &lt;div class="clearboth"&gt;&lt;/div&gt;
             &lt;label class="explabel"&gt;Details of the review: &lt;/label&gt;
                 &lt;textarea id="txtrevdetails" name="txtrevdetails[]" class="expfield" placeholder="Enter details of review"&gt;&lt;?=$expert_details[$i]; ?&gt;&lt;/textarea&gt;
                 &lt;div class="clearboth"&gt;&lt;/div&gt;
                 &lt;input type="hidden" value="&lt;?=$rev_id[$i];?&gt;" name="oldexprevids[]" &gt;
                 &lt;input type="button" class="delReview" id="&lt;?=$rev_id[$i];?&gt;" value="Remove"&gt;
                 &lt;div class="line"&gt;&lt;/div&gt;
             &lt;/div&gt;
  &lt;?php 
      }   
  ?&gt;
  </code></pre>
  
  <p><strong>JS Code:-</strong></p>
  
  <pre><code>/*AJAX Function for Delete Expert Review*/
  jQuery(document).ready(function($) {
  
      $('button.delReview').each(function(){
  
          var $this = $(this);
  
          $this.click(function(){
  
              var deleteItem  = $this.attr('id');
  
              $.ajax({url:'delete-expreview.php?action='+deleteItem}).done(function(data){
  
                  //colect data from response or custom code when success
  
              });
           return false;  
          });
  
      });
  });
  /*End fo AJAX Function*/
  </code></pre>
  
  <p><strong>Delete Page Code:-</strong></p>
  
  <pre><code>    $id = $_REQUEST['action'];
  $sql5 = "delete from cc_tbl_car_review where id = '$id'";
  $result5 = mysqli_query($db,$sql5) or die('Fetch Error');
  </code></pre>
  
  <p>But i am not getting any result.if you have any solution then please share it with me.</p>