How to Delete a MySQL Table Using PHP 


               


How to Delete a MySQL Table Using PHP



PHP







In this article, we show how to delete a MySQL table using PHP.

We delete a table using PHP to write the drop table MySQL query to delete the table.

Shown below is the general format of the MySQL query to delete a table.





So the above is the MySQL code to delete a table.

We'll now show how to tie this MySQL code with PHP to delete a table.



So, first, we must connect to the database.

After we do this, we create a variable named $delete. This $delete variable is set equal to a mysql_query() function that has the parameter "DROP TABLE customers". This deletes the table named customers.

If the table name is entered into a variable, instead of putting the table name directly into the DROP TABLE query statement, put the variable instead.

An example of this is shown in the following link: Code to Delete a MySQL Table Using a Variable for the Table Name.


Related Resources

How to Create a MySQL Table Using PHP

How to Select a Table from a MySQL Database

How to Check if a MySQL Table Exists Using PHP

How to Show All Tables of a MySQL Database Using PHP

How to Delete a Column of a MySQL Table Using PHP

How to Delete a Row of a MySQL Table Using PHP

How to Delete All Rows of a MySQL Table Using PHP

HTML Comment Box is loading comments...