2015-06-21 60 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

相关问题