writting to csv file
Content
Hi ,
i have a requirement where i need to fetch data from database and write into a csv file .
I am not able to write any data into the csv file,csv file that i am getting is blank csv file.
i have tried fpucsv() and fwrite () to write the data.
i am trying this in file manager script.
Attached the code which i have tried.
Thanks.
Version
v1.3Code Snippet
$sToday = date("Y-m-d H:i:s"); $target_path=sys_get_temp_dir(); $sFileName =$target_path."/"."Org_".$sToday.".csv"; $file="Org_".$sToday.".csv"; //header("Content-Type: application/csv"); //header("Content-Disposition:attachment;filename=".$sFileName); echo($sFileName); $header=array(); $sFileOpen = fopen($sFileName, 'w'); if(file_exists($sFileName)) { $fileContent="Account ID,Account Manager,Account Status,Account Type,AccountName,Account's Email Address,Address,Fax Phone,HQ,HierarchyGroup,Industry sector,Merged2AccountDNVGLID,Merged2AccountName,Mobile Phone,OEBS Id,Primary Lang,SalesCloudID,Sanction Status,SanctionComments,SanctionDate,Secondary Lang,SecondaryLanguage,SiebelAccountRowId,TaskId,Validation Status,VAT #,Website,Date Created,Date Last Updated\n"; fwrite($sFileOpen, $fileContent); fclose($sFileOpen); }
0