By following this method, easy to fix, code as follows, useful to the top.
Copy CodeThe code is as follows:
$database = "DatabaseName"; Database name
$user = "root"; Database user Name
$pwd = "PWD"; Database Password
$replace = ' pre_ '; Replaced prefix
$seach = ' pre1_ '; The prefix to replace
$db =mysql_connect ("localhost", "$user", "$pwd") or Die ("Connection Database failed:". Mysql_error ()); Connecting to a database
$tables = Mysql_list_tables ("$database");
while ($name = Mysql_fetch_array ($tables)) {
$table = Str_replace ($seach, $replace, $name [' 0 ']);
mysql_query ("rename table $name [0] to $table");
}
?>
If you add a prefix, you only need to change a little
Copy the Code code as follows:
$table = Str_replace ($seach, $replace, $name [' 0 ']);
$table = $replace. $name [' 0 '];
You can do it.
http://www.bkjia.com/PHPjc/824860.html www.bkjia.com true http://www.bkjia.com/PHPjc/824860.html techarticle by following this method, easy to fix, code as follows, useful to the top. Copy the code as follows: PHP $database = "DatabaseName"; Database name $user = "root"; Database ...