Home > php教程 > php手册 > php 批量删除MySql数据库中相同前缀的表

php 批量删除MySql数据库中相同前缀的表

WBOY
Release: 2016-06-13 10:08:43
Original
970 people have browsed it

php教程 批量删除MySql数据库教程中相同前缀的表



 
   
   
 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
 
   
   
 
   
   
   

批量删除MySQL数据库相同前缀的数

据表 by sudu8

ip地址
数据库账号
数据库密码
数据库
要删除的前缀     ( 例如:bbs_  )
   


if(@$_GET["action"]=="kill"){

if (empty($_POST['ip']))
echo "您没有填写IP地址";
echo "
";
if (empty($_POST['user']))
echo "您没有填写用户名";
echo "
";
if (empty($_POST['pass']))
echo "您没有填写密码";
echo "
";
if (empty($_POST['db']))
echo "您没有填写数据库";
echo "
";
if (empty($_POST['qz']))
echo "您没有填写前缀";
echo "
";
 
 $ip=$_POST['ip'];
 $user=$_POST['user'];
 $pass=$_POST['pass'];
 $db=$_POST['db'];
 $qz=$_POST['qz'];
 
$conn=mysql教程_connect($ip,$user,$pass);
 if (!$conn){
  die ("数据库连接出错! www.zhutiai.com ");
 }
mysql_connect($ip,$user,$pass);

mysql_select_db($db);

$rs=mysql_query('show tables');

while($arr=mysql_fetch_array($rs)){

    $TF=strpos($arr[0],$qz);

     if($TF===0){

        $FT=mysql_query("drop table $arr[0]");

         if($FT){

             echo "$arr[0] 删除成功!
";
       }

              }

            }

}

?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template