-2
我想列出數據庫中的所有表到數組中,然後繼續刪除表內容。我的代碼有什麼問題?用php mysql刪除數據庫表
<?php
mysql_connect('localhost', 'root','');
mysql_select_db(database_name);
$res = mysql_query("SHOW TABLES");
$tables = array();
while($row = mysql_fetch_array($res, MYSQL_NUM)) {
$tables[] = "$row[0]";
}
$length = count($tables);
for ($i = 1; $i < $length; $i++) {
$res = "DELETE FROM $tables[$i]";
mysql_query($res);
echo $res;
$i++;
}
?>
你會得到什麼錯誤?你嘗試過哪些調試? – 2013-03-17 20:38:30