To delete the existing data from the database we first need to establish the database connection. If you didn't know how to establish the database connection , you can visit this article ⇨PHP database connection
For deleting the existing data from the database we just need to learn the query that how to write the delete query with where condition. We have to just pass the connection and delete query with where condition into the mysqli_query() function.
"DELETE FROM table_name WHERE condition"
mysqli_query($connection , $query)
Now we are going to delete the user's from the below users table.
<?php
$conn = mysqli_connect('localhost', 'root', '', 'myfirstdatabase');
mysqli_query($conn,"DELETE FROM users WHERE id=2");
?>
Note ! If you don't write the WHERE condition , then all records will delete.
<?php
$conn = mysqli_connect('localhost', 'root', '', 'myfirstdatabase');
$delete_id = '2';
mysqli_query($conn,"DELETE FROM users WHERE id='".$delete_id."' ");
?>