php force download csv
snippet in php

php force download csv

user6664

  header('Content-Type: text/csv');
  header('Content-Disposition: attachment; filename="ramais.csv"');

  $saida = $stmt->fetchAll(PDO::FETCH_ASSOC);
  echo "id;nome;ramal;email;setor;diretor\r\n";
  foreach ($saida as $s){
  	foreach ($s as $k => $v){
  		echo "{$v};";
	  }
	  echo "\r\n";
  }