I am trying to export sql query result to a file so that I can provide user a download link to download. But I am getting some issues:
Issue 1: After execution I could not find data.csv in the root folder.
Issue 2: If I try again then it says that file already exists.
I am using following code:
$query = <<<EOL
SELECT * FROM data
INTO OUTFILE '/data.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '
'
EOL;
$result = mysql_query($query);
Solutions I want:
1- I need to know from where I can locate file.
2- I need to be able this csv file through php after execution.
Details about the Environment I am using for this script: