How Can I Delete Records Into Table Using Mysqli and PDO?

WHERE clause is used with DELETE table_name statement when row or record is to be deleted.

DELETE FROM table_name 
WHERE column_name=some_value

Example for DELETE statement using MySQLi

<?php
$server = "localhost";
$user = "root";
$password = "";
$db = "expertstutorials";
$conn = mysqli_connect($server, $user, $password, $db);
if($conn){
echo "Connected successfully.";
}
else{
echo "Connection failed : ".mysqli_connect_error();
}
$table_delete = "DELETE FROM course WHERE id=2";
if (mysqli_query($conn, $table_delete)) {
echo "Some row deleted successfully.";
} else {
echo "Row deleting failed : " . mysqli_error($conn);
}
mysqli_close($conn);
?>

Example for DELETE statement using PDO

<?php
$server = "localhost";
$user = "root";
$password = "";
$db = "expertstutorials";
try{
$conn = new PDO("mysql:host=$server;dbname=$db", $user, $password);
echo "Connected successfully.";
$table_delete = "DELETE FROM course WHERE id=2";
$conn->exec($table_delete);
echo "Some row deleted successfully.";
}
catch(PDOException $e){
echo "Row deleting failed : " . $e->getMessage();
}
$conn = null;
?>