If you want to Drop a table from a database with PHP MySqli you must make sure that the table is there in the first place. If you have not done so please see Create a New Table in a MySqli Database. To drop a table use the following code. You must make sure of the following requirements.
- You Created A Database
- You Granted Privileges to the database
- Created a config.php file to access the database
The following code will drop a database called “MyDb” so you will have to be sure to adjust the code to match the table that you want to drop in your database. 😉
[code]include(‘config.php’);
// Create connection
$con = new mysqli($host, $username, $password, $dbname);
$con ->query("DROP TABLE myDb");
$con ->close();[/code]
If you want more detailed explanations on dropping a database see the php site.
A1WEBSITEPRO Social Media Pages
Here are my social media pages, lets hook up!