[Solved] Make calculations in csv with php


I would maybe do it more simple. If you didn’t know how many columns you could do the extra loops to get column names, but it does not look necessary.

$output = "datetime, value1, value2\n"; // Column names
while ($row = mysql_fetch_array($sql)) {
  $output .='"' . $row[0] . '" ,';
  $output .='"' . $row[1] . '" ,';
  $output .='"' . ($row[1] * 5) . '"';
  $output .="\n";
}

3

solved Make calculations in csv with php