2015-06-21 82 views
-2

我正在使用此代碼向我連接到的數據庫顯示錶的列表,但我無法將它們放入字符串中。 什麼,我想發生是從數據庫中獲取表的列表,並將其存儲在一個字符串在數據庫中獲取表並將其存儲在字符串中

$result = mysql_query("show tables"); // run the query and assign the result to $result 

while($table = mysql_fetch_array($result)) { // go through each row that was returned in $result 
    if ($table) { 
     $aw = array(); 
     $count= 0;        
     $aw[$count] = $table[0]; 
     echo $string = array($aw[$count]); 

     $count++; 
    } 
} 

回答

0

爲什麼要使用echo $string = array($aw[$count]);

在我看來這應該解決它太:

echo $string = $aw[$count];

當你評論,你想擁有它CSV格式,你可以,如果你想要把在fputcsv例如看看它直接到一個文件。否則,這裏是一個產生CSV字符串的function

+0

謝謝,但我也想在CSV格式的數據 – VicGomez

+0

那麼只要看看編輯的答案。 – Ionic

+0

我不明白如何產生CSV字符串的功能可以幫助我 – VicGomez

相關問題