-4

在尝试提交之前,我需要清理几个数据库中的几个表

$db_server = include('root.php');
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
$sqla = "TRUNCATE TABLE `info`.`2012_august`";
$sqlb = "TRUNCATE TABLE `stu`.`2012_august`";
$sqlc = "TRUNCATE TABLE `stu`.`2012`";
if (@mysql_query($sqla))
    {
    echo ("success"."</br>");
    }
else
{
    echo ("un success".mysql_error()."</br>");
     }

只有第一个表清除其数据。我该如何解决这个问题。

4

3 回答 3

1

您的代码只是在执行$sqla。您需要执行其他的,或者将它们组合成一个用分号分隔的。

于 2012-08-11T09:30:49.157 回答
0

你有

$sqla = "TRUNCATE TABLE `info`.`2012_august`";
$sqlb = "TRUNCATE TABLE `stu`.`2012_august`";
$sqlc = "TRUNCATE TABLE `stu`.`2012`";

要存储的值。但您只用于$sqla存储。这就是其他值不存储的原因。You have to store them all by using commaby storing all the values into an array and call them at the time of store

于 2012-08-11T09:35:52.897 回答
-2
$a = array("TRUNCATE TABLE `info`.`2012_august`",   // create an array of queries
           "TRUNCATE TABLE `stu`.`2012_august`", 
           "TRUNCATE TABLE `stu`.`2012`");

foreach ($a as $value) {                            // iterate through array
    if (@mysql_query($value))
    {
        echo ("success"."</br>");
    } else {
        echo ("un success".mysql_error()."</br>");
    }
}
于 2012-08-11T09:34:04.270 回答