delete query in php mysql || How to delete data from database in PHP using button delete

Agra If you want to delete insert value in any table in database then how can you delete it with the help of mysqli_query By doing this we can give button to delete any data on any website as well as ready delete option So that whenever someone clicks on the delete button, the value will be deleted.

 

<?Php $servername = "localhost";
$username = "u336260023_user";
$password = "mypassword";
$dbname = "u336260023_user";

$conn = mysqli_connect($servername,$username,$password,$dbname);

$ID = "2"

$query = mysqli_query($conn,"DELETE FROM `dldata` WHERE `dldata`.`id` = $ID;
") ;

if($query ==TRUE){
    echo '<script type="text/javascript">
                                        alert("Delete Successfully");
            window.location.href = "dlcardlist.php"
        </script>';
}else{
                                        echo '<script type="text/javascript">
                                        alert("Something went wrong Please try again");
            window.location.href = "dlcardlist.php"
        </script>';
                                    }
?>

HTML

You can edit this code and use it, for this you have to give the user and password to connect to the database, as well as mention the name of the table and also the column, then you have to pass a condition in the ware that when it Whether it is a value or when such a value comes which is added to the database, then the full value of that line should be deleted.