I use the following way to try export the data to a csv file, the methoid I am using is from the below link Problem in Export csv file in php, but when I try to export the file, the system replys me no such file can be read, so I would like to ask I have to pre-open a result.csv first before I execute the code? Or the file result.csv has already generated, but in a wrong directory, if this is the reason, may I ask how can I define the directory the file should be created in.
$result = mysql_query("SELECT TechName, ClientName, SiteName, Time, Type
INTO OUTFILE 'result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED by '\"'
LINES TERMINATED BY '\n'
FROM Tech AS T, Client AS C, Site AS S, Log AS L
WHERE T.TechID=L.TechID AND C.ClientID=L.ClientID AND S.SiteID=L.SiteID
ORDER BY L.Time DESC");
$Time = date('Y_m_d_H_i');
$fileName = "Report_".$Time.".csv";
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="'.$fileName.'"');
readfile('result.csv');