Home > Backend Development > PHP Tutorial > PHP batch delete tables with the same prefix in MySql database_PHP tutorial

PHP batch delete tables with the same prefix in MySql database_PHP tutorial

WBOY
Release: 2016-07-13 17:05:40
Original
1156 people have browsed it

php tutorial batch delete tables with the same prefix in MySql database tutorial





























Delete the number of the same prefix in MySQL database in batches

Data table by sudu8

ip address
Database account
Database password
Database
Prefix to be deleted ( For example: bbs_  )


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

if (empty($_POST['ip']))
echo "You did not fill in the IP address";
echo "
";
if (empty($_POST['user']))
echo "You did not fill in the username";
echo "
";
if (empty($_POST['pass']))
echo "You did not fill in the password";
echo "
";
if (empty($_POST['db']))
echo "You did not fill in the database";
echo "
";
if (empty($_POST['qz']))
echo "You did not fill in the prefix";
echo "
";

$ip=$_POST['ip'];
$user=$_POST['user'];
$pass=$_POST['pass'];
$db=$_POST['db'];
$qz=$_POST['qz'];

$conn=mysql tutorial_connect($ip,$user,$pass);
if (!$conn){
die ("Database connection error! 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] deleted successfully!
";
}

         }

         }

}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630750.htmlTechArticlephp tutorial batch delete tables with the same prefix in MySql database tutorial form id=form1 name=form1 method=post action= ?php echo $PHP_SELF; ?? action=kill table width=425 border=0 align=cente...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template