I would like to take everything from my table and create a comma delimenated text file.
i would like my data to appear in the text file like this:
1,john,smith,35,red
2,mary,jane,31,blue
3,jack,black,11,green
.
.
.
i've been trying to use:
$db_name = "some_db";
$table_name = "some_table";
$connection = @mysql_connect("xxx", "xxx", "xxx") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection)or die("Couldn't select database.");
$sql = "SELECT * INTO OUTFILE '/path.../filename/test.txt'
FIELDS TERMINATED BY ','
LINES TERMINATED BY \"\n\"
FROM $table_name
";
$result = @($sql,$connection)or die("$sql");
It is not working though, the file test.txt is not being created in the folder filename.
Also, what if i want the user to specify the file name, can i substitute
'/path.../filename/test.txt' to
'/path.../filename/$filename.txt'
Thanks for any help 🙂