You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

writting to csv file

Received Response
18
Views
2
Comments
edited Jun 8, 2022 12:06PM in General Technical Discussions 2 comments

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.3

Code 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);
						
						
						 
			  
					 } 
        

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!