-2

I am using this code to show list of tables to the database i am connected to but I cant place them in a string. What i would like to happen is to get the list of tables from the database and store them in a string

$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++;
    }
}
Ionic
  • 3,884
  • 1
  • 12
  • 33
VicGomez
  • 21
  • 2

1 Answers1

0

Why do you use echo $string = array($aw[$count]);.

In my opinion this should solve it too:

echo $string = $aw[$count];

As you commented you would like to have it in a CSV format, you can take a look at fputcsv for example if you want to put it to a file directly. Otherwise here is a function which produce a CSV string.

Community
  • 1
  • 1
Ionic
  • 3,884
  • 1
  • 12
  • 33