There are more ways to delite a MySQL database in PHP. PDO (PHP Data Objects) is the best of them.
Advantages of PDO is a consistent interface across many different types of database, uses an object-oriented approach, and supports more features offered by newer databases.

Using a PDO recommends wherever possible.


How to delete MySQL database - Example

<?php
try{ 
    
$pdo = new PDO("mysql:host=localhost", "yourusername", "yourpassword"); 
    
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
} catch(
PDOException $e){ 
    die(
"ERROR: Could not connect. " . $e->getMessage()); 
} 
  
try{ 
    
$sql = "DROP database DEMO"; 
    
$pdo->exec($sql); 
    echo 
"Database DEMO deleted successfully."; 
} catch(
PDOException $e){ 
    die(
"ERROR: Could not able to execute $sql. " 
                                
. $e->getMessage()); 
} 
unset(
$pdo); 
?>