We can delete existing records only from MySQL table.

Syntax

DELETE FROM table_name WHERE condition;

  • Delete table’s existing record from table on the basics of their phone number.

File – form1.html

<!DOCTYPE html>
<html lang=”en”>
<head>
    <meta charset=”UTF-8″>
    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
    <title>form 1</title>
</head>
<body>
    <br>
    <font style=”font-size: 20px;”>Enter Customer Phone Number[deleting record]</font>
    <br>
    <br>
    <form action=”form1.php” method=”post”>
        <font style=”font-size: 20px;”>Customer Phone Number</font>
        <br>
        <input type=”text” name=”phoneno”>
        <br>
        <br>
        <input type=”submit” value=”delete”>
    </form>
</body>
</html>
output

File – form1.php

<?php
error_reporting(0);
// establishing database connection
$conn = mysqli_connect(‘localhost’,’root’,”,’microcodes’);
 
$phone = $_POST[‘phoneno’];
 
$sql=”DELETE FROM customers WHERE phone=’$phone'”;
$query = mysqli_query($conn,$sql);
 
if($query){
    echo “<br><font color=’red’ size=’20px’> record deleted!!</font>”;
    echo “”;
}
else{
    echo “<br> record not deleted!”;
}
?>
output

Note: from the above code, you see 2nd record of ‘priya mohanto’ on the basics of phone number.

File – phpmyadmin before

File – phpmyadmin after