1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)

Drop a table from a database with PHP MySqli

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.

  1. You Created A Database
  2. You Granted Privileges to the database
  3. 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. 😉

include('config.php');
// Create connection
$con = new mysqli($host, $username, $password, $dbname);
$con ->query("DROP TABLE myDb");
$con ->close();

If you want more detailed explanations on dropping a database see the php site. 

Drop a table from a database with PHP MySqli was last modified: October 18th, 2015 by Maximus Mccullough

Subscribe To My YouTube Channel:
Advanced Programming Made Easy

I hope you enjoyed the article. If I was able to help you please consider a tip for the content.

One Time Tip

more tips

Reoccuring Tips

Tips

Drop a table from a database with PHP MySqli

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.