How to Delete a Column of a MySQL Table Using PHP 


               


How to Delete a Column of a MySQL Table Using PHP



PHP







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

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

The general format of the MySQL query to delete a column of a MySQL table is shown below.





So the above is the MySQL code to delete a column named email of a MySQL table.

We'll now show how to tie this in with PHP to delete a column of a table.



So, first, we must connect to the database.

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

So this is how you can delete a column from a MySQL table using PHP.


Related Resources

How to Delete a MySQL Table Using PHP

How to Add a Column to a MySQL Table Using PHP

How to Add a Primary Key to a Column of a MySQL Table Using PHP

How to Make a Column of a MySQL Table Unique Using PHP

How to Rename a Column of a MySQL Table Using PHP

How to Concatenate Column Values in MySQL Using PHP

How to Set the Default Value of a Column of a MySQL Table Using PHP

How to Drop the Default Value of a Column Of a MySQL Table Using PHP

How to Modify the Defintion or Data Type of 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

How to Copy a Table Definition in MySQL Using PHP

HTML Comment Box is loading comments...