title: deleting a selected row by sending it id from javascript to php page
body: <p>i didn't find a similar post, i am trying to post an array from a javascript to a php page called delete.php, i want to delete a row whene clicking on the delete button situated in the last column Which is displayed by bye the php page select like this .</p>
  
  <pre><code>  while($row = mysqli_fetch_array($result))
   { 
   ?&gt;
   &lt;tr&gt;
    &lt;td&gt;&lt;?php echo $row['code'] ;?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['designiation'] ;?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['diametre'] ;?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['epaisseur'] ;?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['prix'] ;?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['etat'] ;?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['id'] ;?&gt;&lt;!--style="display:none;"--&gt;
  
    &lt;td&gt;&lt;button type="button" class="btn btn-success btn-edit"&gt;Modifier     &lt;/button&gt; | 
        &lt;button type="button" onclick="pdelete();" class="btn btn-danger btn-delete"&gt;Supprimer  &lt;/button&gt;
    &lt;/td&gt;
  
   &lt;/tr&gt;
  </code></pre>
  
  <p>as you see here the function pdelete() is on the onclick of the button and the id is btn-delete so i did like this </p>
  
  <pre><code>  function pdelete(){
  
      var _id = $('input[name="idrow"]').val();
      var _type = $('#typeid').val();
      var _pression = $('#pressionid').val();   
      var _code = $('input[name="code"]').val();
      var _designiation = $('input[name="designiation"]').val();
      var _diametre = $('input[name="diametre"]').val();
      var _epaisseur = $('input[name="epaisseur"]').val();
      var _prix = $('input[name="prix"]').val();
      var _etat = $('input[name="etat"]').val();
  
      $.post('delete.php', {postid:_id, posttype:_type, 
                            postpression:_pression, postcode:_code, 
                            postdesigniation:_designiation, 
                            postdiametre:_diametre, 
                            postepaisseur:_epaisseur, postprix:_prix, 
                            postetat:_etat}, 
            function(data){
              $('tbody').append(data);
            });
      }
  
      $(document).on('click','.btn-delete', function(){
  
          _trEdit = $(this).closest('tr');
          var _id = $(_trEdit).find('td:eq(6)').text();
          $('input[name="idrow"]').val(_id);
  
          if(confirm("Vous etes sur de supprimer cette ligne?")){
              $(this).closest('tr').remove(); 
              alert("suppression réussite .");
          }
  });
  </code></pre>
  
  <p>the page delete.php is like this </p>
  
  <pre><code>$id_tube = $_POST['postid'];
  $type_utilisation = $_POST['posttype'];
  $pression_tube = $_POST['postpression'];
  $code_tube = $_POST['postcode'];
  $designiation_tube =$_POST['postdesigniation'];
  $diametre_tube = $_POST['postdiametre'];
  $epaisseur_tube = $_POST['postepaisseur'];                       
  $prix_tube =$_POST['postprix'];
  $etat_tube = $_POST['postetat'];
  
  
  if(isset($pression_tube)){
      if($pression_tube=="pn4"){
          if($type_utilisation=="pehdtelecom" &amp;&amp; $pression_tube=="pn4" ){ echo "verifier le type du Tube S.v.p";}else{
  
              $sql="DELETE from  pn4  where id='".$id_tube."'";    
              echo"$sql";  
              $result = mysqli_query($link, $sql);
  
              // echo"$id_tube";
              if($result){
                  // do something here 
  
              } else{
                  echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
              }
      }
  }
  </code></pre>
  
  <p>it doesnt find the id and it did not pass through post. to put it in the condition of the sql request in the delete.php page , i have tried almost evrything a i found i am out of idea please help me to solve it to delete the row from the database also when clicking the delete button in the last column. </p>