How to Highlight a Deleted Row in PHP

Today, We will see how to delete a record without refreshing the Page using PHP and AJAX . How to Highlight a Deleted Row in PHP.

Check out our More tutorial in PHP

Netflix clone app using Laravel

login form in React with Laravel

PHP CRUD Application using OOP and MYSQL

PHP MySQL Ajax Live Search

Delete the Record without Refreshing the Page

The below snippet is showing How We can highlight the Row with Jquery. I am using the Jquery Ajax technique for deleting the row, You can use Javascript As well.

Learn JQUERY from here

Delete row without refreshing the page in PHP

Our Database name is the test you can change the DB Name according to your choice.

Highlight the deleted row in PHP

Now we will see our code part here

I have made two files here one is our Landing page or you can say the main page ( Index Page ) . One file is for performing delete action.


<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="">
  <link rel="stylesheet" href=""/>

<div class="card text-center" style="padding:15px;">
  <h4>PHP: Delete using AJAX Technique</h4>

<div class="container">
 <div class="row">
  <div class="col-sm-10">
    <table class="table table-hover table-bordered ml-4 ">
        <tbody id="output">
            $conn = mysqli_connect('localhost','root','','test');

            $sql_select = "SELECT * FROM student";
            $sel_query =  mysqli_query($conn,$sql_select);
            while($row = mysqli_fetch_array($sel_query))
                echo'<tr id="'.$row['id'].'">';
                 echo'<td> <button  class="remove" name="remove" id="'.$row['id'].'"><i class="fas fa-trash" style="color:red"></i></button></td>';

<script src=""></script>
<script src=""></script>

        var userID = $(this).attr('id');
            type: "POST",
            url: "delete.php",
            data: {deleteID:userID},
            success: function(data)
                    if(confirm('Are you sure you want to delete this?'))
                       $('#' + userID).css("background-color", "palegreen");
                        setTimeout(function() {
                          $('#' + userID).remove();
                      //  $('#' + userID).remove();
        // }

Now Here is the Delete record code in PHP

    $conn = mysqli_connect('localhost','root','','test');

    $deleteID = $_POST['deleteID'];

    $sql_select = "DELETE FROM student WHERE id = $deleteID";
    $sel_query =  mysqli_query($conn,$sql_select);
        echo "Success";
        echo "Error";


Now You can run the project in your Browser

Subscribe to My Programming YouTube Channel Before Downloading the code :

Download the Code from here: Highlight deleted row in PHP

Learn More about PHP and React

Display Selected Row record in Material UI Model Box using React

Codeigniter 4 CRUD Operation With Ajax Example

Netflix clone app using Laravel

Leave a Reply

Your email address will not be published. Required fields are marked *