Method One:
Copy Code code as follows:
<?php
Mysql_connect (', ', ', ');
mysql_select_db (");
$rs =mysql_query (' Show Tables ');
while ($arr =mysql_fetch_array ($rs)) {
$TF =strpos ($arr [0], ' class_ ');
if ($TF ===0) {
$FT =mysql_query ("drop table $arr [0]");
if ($FT) {
echo "$arr [0] Delete success! <br> ";
}
}
}
?>
Method Two:
Today to reload a station, engaged in the afternoon, finally found a can be used to delete the database table method ...
This is a xx_-prefix demonstration, you can change yourself to delete the table prefix
Copy Code code as follows:
<?php
function Deldata ($dbname, $tableflag) {
$db _host = ' localhost ';
$db _port = ' 3306 ';
$db _user = ' user ';
$db _pass = ' password ';
$connect =mysql_connect ($db _host, $db _user, $db _pass);
mysql_select_db ($dbname);
$result = mysql_query ("Show Table status from $dbname", $connect);
$data =mysql_fetch_array ($result);
while ($data =mysql_fetch_array ($result)) {
$table =mysubstr ($data [Name], "_");
if ($table = = $tableflag) {
For testing
/*echo $data [Name];
echo "
";
Echo $table;
echo "
";*/
mysql_query ("drop table $data [Name]");
}
}
return true;
}
/* All character functions prior to intercepting a particular character
* $STR to intercept string
* $flag Specific characters Furu "_"
*/
function Mysubstr ($STR, $flag) {
$pos =strpos ($str, $flag);
Return substr ($str, 0, $pos);
}
?>
The change is in:
1. At the beginning
<?php
function Deldata ($dbname, $tableflag) {
$db _host = ' localhost ';
$db _port = ' 3306 ';
$db _user = ' user ';
$db _pass = ' password ';
Change to your database address, account number and password
2. At the end
Change to your database name and the table prefix you want to delete
You can copy the above code to save it as. php and upload it to the space directory.