I'm trying to create a PHP page that opens the query and automatically updates the csv file with a new value.
I disc location I have file "graph.csv" with date, and COUNT from SQL Query. I try open this file and add new row everytime when page is loaded. But, currently browser try save and overwrite file manual. php and csv file are in the same location.
<?php
$connect = oci_connect("login","pass","db");
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=graph.csv');
$output = fopen("php://output", "w");
fputcsv($output, array('TIME','Orders'));
$query = "SELECT column1, column2 FROM table1";
$result = oci_parse($connect, $query);
$r=oci_execute($result);
while ($row = oci_fetch_array($result, OCI_BOTH))
{
$handle = fopen("graph.csv", "a");
$handle = fputcsv($output, $row);
}
$handle = fclose($output);
?>