Jump to content

I have come so far


kimjessen

Recommended Posts

hi! 
I work a little to save some data in a CSV file. 
and I have come so far
$date = date('dmy');

    define("LOG_FILE", $date);

	if(!isset($_GET["temp"])) ;


	$temp = $_GET["temp"];

    $date=gmdate("Y-m-d-h-i", time());
    
	$file_handler = fopen(LOG_FILE, "a+");
	fwrite($file_handler, $date . "," . $temp . "\n");
	fflush($file_handler);
	echo "OK";
it works well. 
 
I would like to combine the filename with a text FX. water level + the date .csv 
 
but I can not get it to work for someone who will help

 

Link to comment
https://forums.phpfreaks.com/topic/290867-i-have-come-so-far/
Share on other sites

have solved it

	$date = date('dmy');
	$prefix="Temp-";
        $suffix=$date;
        $filename=$prefix.$suffix.".csv";   //         Solution
	
    
    define("LOG_FILE", $filename);

	if(!isset($_GET["temp"])) ;


	$temp = $_GET["temp"];

    $date=gmdate("Y-m-d-h-i", time());
    
	$file_handler = fopen(LOG_FILE, "a+");
	fwrite($file_handler, $date . "," . $temp . "\n");
	fflush($file_handler);
	echo "OK";
Link to comment
https://forums.phpfreaks.com/topic/290867-i-have-come-so-far/#findComment-1490032
Share on other sites

why do you create so many extra variables that you never reuse? And create variables and then just store them in another variable?

  1. $date = date('dmy');
    $prefix="Temp-";
    $suffix=$date;
    $filename=$prefix.$suffix.".csv"; // Solution
    
    
$filename = 'Temp-' . date('dmy') . '.csv';
Link to comment
https://forums.phpfreaks.com/topic/290867-i-have-come-so-far/#findComment-1490055
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.