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
Post a Comment