Delete a table from database in PHP

avatar December 25, 2011 by: 7

Prior to this see : How to create and insert a row into table in PHP
 Delete a row in a table in PHP

Now we are going to see how to delete a table from a database. The code for it goes here.

<?php
//connecting to host
mysql_connect("localhost", "root", "");
//Selecting a specific Database from available databases
mysql_select_db("Example");
//Deleting a table from database
if(!mysql_query("drop table MyTable"))
{
    echo 'Error'.mysql_error();
}
else
{
    echo 'Deleted';
}
?>

Here we use DROP to delete a table from a database. So if you want to delete any table from a database you need to use this

mysql_query("DROP TABLE MyTable");

where ‘MyTable’ is name of the table.

See Next>>  How to edit(update) a field in a table in PHP

Share this Story
Categories
Php  
Tags
Add a Comment on "Delete a table from database in PHP"

    7 Comments on "Delete a table from database in PHP"

  1. you are really a good webmaster, you have done a well job on this topic!

  2. Needed to create you that bit of observation to finally say thanks a lot again for the spectacular

  3. can someone here tell me how to set that up?

  4. wonderful publish, very informative. I’m wondering why the other experts of this sector don’t understand this. You must continue your writing. I’m sure, you have a huge readers’ base already!

  5. avatar Mirtha Koury says:

    I always was interested in this subject and stock still am, thanks for putting up.

  6. avatar Dane Zhang says:

    I am impressed with this website, really I am a fan.

Follow us

About Techdigit

Tech Digit comprises of many authors but the CEO of techdigit is Sriram who is an internet Marketer and Entrepreneur.