有人可以告訴我如何保存兩個數據庫表中的字段嗎?php/mysql SHOW COLUMNS from table1 and table2
也能正常工作爲一個表:
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table." WHERE Field NOT IN
('ID','Key','Text');");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."; ";
$i++;
}
}
$csv_output .= "\n";`
我需要從兩個不同的表中的字段。我在同一臺機器上有兩個數據庫。表格中的字段名稱不同。
這是不工作:
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
mysql_select_db($db2) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table." , ".$table2." WHERE Field NOT IN
('ID','Key','Text');");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."; ";
$i++;
}
}
$csv_output .= "\n";
字段 「ID」, 「鍵」 和 「文本」 僅在DB1存在。
有什麼錯誤? – 2012-08-09 10:00:30