I have a code that allows me to export information from a table in my database, but I would like it that every time you export to the file, put the name of the column.
<?
if($_POST[exportar] == "expbas"){
$consulta = "SELECT * FROM pruebas WHERE (fecha BETWEEN '".$_POST[fecha_inicial]."' AND '".$_POST[fecha_final]."')";
$result = $usuario->consulta($consulta);
$arr_datos = $usuario->ciclo_de_filas($result);
$file = fopen("tmp/base_".str_replace("-","",$_POST[fecha_inicial])."_".str_replace("-","",$_POST[fecha_final]).".csv", "w");
for($xx = 0; $xx < count($arr_datos); $xx++){
fwrite($file, $arr_datos[$xx][expediente].";".$arr_datos[$xx][fecha]. PHP_EOL);
}
fclose($file);
?>