jquery - unable to delete record with php and ajax -


i'm trying delete record row id table using php , ajax when click on button neither shows error nor performs action.

here delete.php code:

<?php session_start(); include 'db.php';  if(isset($_get['name'])){ $user = $_get['name'];  $query = mysqli_query($con, "select * login username='$user'") or die (mysqli_error());  $result = mysqli_num_rows($query); while($row = mysqli_fetch_array($query)){  $_session['user'] = $row['username']; } }  $query = mysqli_query($con, "select * pm touser = '".$_session['user']."' order pmdate desc" ) or die (mysqli_error()); $result = mysqli_num_rows($query);  while($row = mysqli_fetch_array($query)){ $id = $row['id'];  $delquery = mysqli_query($con, "delete * pm id ='$id'") or die (mysqli_error()); $delresult = mysqli_num_rows($delquery);  } ?> 

and here ajax , delete code of html

<a href="home.php?name='.$_session['user'].'-delid='.$id.'" type="button" class="btn btn-danger btn-sm" id="delete"></a>  <script> $("#delete").click(function() { $.ajax({ type: "post", url: "delete.php", success: function(response){                     $("#messages").html(response);  } }); }); </script> <div id="messages"></div> 

any 1 have ideas?

change query

-> "delete * pm id ='$id'"

-> correct "delete pm id ='$id'"

you send post method true ajax , in php code write get, change it.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -