Heim >Backend-Entwicklung >PHP-Tutorial >php 批量删除MySql数据库中相同前缀的表_PHP教程
php教程 批量删除MySql数据库教程中相同前缀的表
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] 删除成功!
";
}}
}
}
?>