note 35643 added to function.mysql-list-tables
| From: | wbphfox at xs4all dot nl | Date: | Tue, 09 Sep 2003 13:55:04 +0000 |
| Subject: | note 35643 added to function.mysql-list-tables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55892@lists.php.net to get a copy of this message | ||
Here is a way to show al the tables and have the function to drop them...
<?php
echo "<p align=\"left\">";
//this is the connection file for the database....
$connectfile = "connect.php";
require $connectfile;
$dbname = 'DATABASE NAME';
$result = mysql_list_tables($dbname);
echo "<table width=\"75%\" border=\"0\">";
echo "<tr bgcolor=\"#993333\"> ";
echo "<td><font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-1\" color=\"#FFFFFF\">Table name:</font></td>";
echo "<td><font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-1\" color=\"#FFFFFF\">Delete?</font></td>";
echo "</tr>";
if (!$result) {
print "DB Error, could not list tables\n";
print 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
echo "<tr bgcolor=\"#CCCCCC\">";
echo "<td>";
print "$row[0]\n";
echo "</td>";
echo "<td>";
echo "<a href=\"$PHP_SELF?action=delete&table=";
print "$row[0]\n";
echo "\">Yes?</a>";
echo "</td>";
echo "</tr>";
}
mysql_free_result($result);
//Delete
if($action=="delete")
{
$deleteIt=mysql_query("DROP TABLE $table");
if($deleteIt)
{
echo "The table \"";
echo "$table\" has been deleted with succes!<br>";
}
else
{
echo "An error has occured...please try again<br>";
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.mysql-list-tables.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35643
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35643&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35643&report=yes