我正在尝试将数据库中的所有表列出到一个数组中,然后继续删除表的内容。我的代码有什么问题?
<?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++;
}
?>