Friday, January 27, 2017
DELETE ROW WITHOUT REFRESHING PAGE IN PHP
<tr><a href="" id="'.$row['rec_id'].'" class="delbutton"><b>Delete</b></a></tr>
<script type="text/javascript" >
$(function() {
$(".delbutton").click(function() {
var del_id = $(this).attr("id");
var info = 'id=' + del_id;
var thisTableRow = $(this).closest('tr');
if (confirm("Sure you want to delete this post? This cannot be undone later.")) {
$.ajax({
type : "POST",
url : "delete_pdf.php", //URL to the delete php script
data : info,
success : function() {
alert("PDF Successfully deleted!");
$(thisTableRow).hide("fast");
}
});
}
return false;
});
});
</script>
delete_pdf.php
<?php
require_once('mysql_connect.php');
$id=$_POST['id'];
$delete = "DELETE FROM uploaded_tax_files WHERE rec_id='$id'";
$result = mysql_query($delete) or die(mysql_error());
?>
Subscribe to:
Post Comments (Atom)
thanks
ReplyDelete