php教程 批量刪除MySql數據庫教程中相同前綴的表
<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>?
action=kill">
<table width="425" border="0" align="center">
<tr>
<td height="46" colspan="2" align="center"><p>批量刪除MySQL數據庫相同前綴的數據表 by <a href="http://www.bKjia.c0m" target="_blank">sudu8</a></p></td>
</tr>
<tr>
<td width="103">ip地址</td>
<td width="306" height="26"><label>
<input name="ip" type="text" id="ip" value="localhost" />
</label></td>
</tr>
<tr>
<td height="25">數據庫賬號</td>
<td height="26"><label>
<input type="text" name="user" id="user" />
</label></td>
</tr>
<tr>
<td>數據庫密碼</td>
<td height="26"><label>
<input type="text" name="pass" id="pass" />
</label></td>
</tr>
<tr>
<td>數據庫</td>
<td height="26"><label>
<input type="text" name="db" id="db" />
</label></td>
</tr>
<tr>
<td>要刪除的前綴</td>
<td height="26"> <label>
<input type="text" name="qz" id="qz" />
</label>( 例如:bbs_ )</td>
</tr>
<tr>
<td height="67" colspan="2" align="center"> <label>
<input type="submit" name="tijiao" id="tijiao" value="開始刪除" />
</label></td>
</tr>
</table>
</form>
<?phpif(@$_GET["action"]=="kill"){
if (empty($_POST['ip']))
echo "您沒有填寫IP地址";
echo "<br>";
if (empty($_POST['user']))
echo "您沒有填寫用戶名";
echo "<br>";
if (empty($_POST['pass']))
echo "您沒有填寫密碼";
echo "<br>";
if (empty($_POST['db']))
echo "您沒有填寫數據庫";
echo "<br>";
if (empty($_POST['qz']))
echo "您沒有填寫前綴";
echo "<br>";
$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] 刪除成功!<br>";
}}
}
}
?>