How to Delete Record from MySQL Table with AJAX
You can do this with jQuery AJAX where you need to pass the record id from AJAX which needs to delete. your page is not a load. AJAX is not a page load.
This Code use for your record file. <?php $(function() { $(".delete").click(function(){ var element = $(this); var del_id = element.attr("id"); var info = 'id=' + del_id; $.ajax({ type: "POST", url: "delete_job.php", data: info, success: function(){ swal({ title: 'Are you sure?', text: "You won't be able to revert this!", type: 'success', confirmButtonColor: '#3085d6', confirmButtonText: 'Ok' }).then(function () { window.location.assign('view_job.php'); }); } }); $(this).parents(".show").animate({ backgroundColor: "#003" }, "slow") .animate({ opacity: "hide" }, "slow"); return false; }); }); ?> You are create a one Dalete.php file than after you are add this code. <?php include("config.php"); session_start(); if($_POST['id']) { $id=mysqli_real_escape_string($connection, $_POST['id']); $delete = "DELETE FROM `post_job` WHERE id='$id'"; mysqli_query($connection, $delete); } ?> This code your button code and use for button is your all record show. <a data-id="<?php echo $row['id'];?>" id="<?php echo $row['id'];?>" class="btn btn-theme btn-xs btn-default delete">Remove</a></td>
Author: Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.
Trending Posts
Tags
ACF
Ading custom columns
admin
Bootstrap
Cart Price
categories
Change Price
class
Code
comments
Create
Creating custom post Type
CSS
current
custom
Customizing
Custom Post
Custom Post Type
Custom Taxonomy
database
Date
Fatch
form
function
HTML
Image
Install
javascript
jQuery
Menu
PHP
Post
Post Type
Price
product
responsive
Resular price
Single product
Table
taxonomy
Theme
Title
woocommerce
Wordpress
Wordpress Code