PHP Delete Data


After Inserting data if you want you can delete the data.Here we are delete data depending upon the id in our table.
<?php
include('config.php');
// sql to delete a record $sql = "DELETE FROM Your_table_name WHERE id=3";

if ($conn->query($sql) === TRUE) 

{
    echo "Record deleted successfully";

else 
{
    echo "Error deleting record: " . $conn->error;
}


?>


If the id 3 exixts in our table then the data will be deleted otherwise error will be display.

0 Comments