I have the following code:
$Name = 'NOMINA-'.$mes.'-'.$dia.'-'.$ano.'.csv';
$rpedidos = "SELECT total,
cuenta FROM nomina";
$reg = $conexion->query($rpedidos);
while( $reg_File = $reg->fetch_array() )
{
$ceros="000";
$ttpago=number_format($reg_File["total"],2);
$ctaBco=$reg_File["cuenta"];
$tt="".$ctaBco."".$ceros."".$ttpago."";
$shtml = $tt."\n";
}
//$shtml=$excel;
//$shtml=$shtml."</table>";
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header('Content-Disposition: attachment; filename='.$Name.'');
echo $shtml;
It generates me Perfectly, CSV but it divides the totals into two columns and I only need it in one, some guide.
Thanks.
Note that the
CSV
are files where the values are separated by:,
);
) where the regional configuration uses the comma as the decimal separator, example: Argentina, Brazil, Spain, etc.For either of these cases, the way to escape the separator is to print the value in double quotes (
"
).Solution:
PS: Double quotes are escaped with double quotes, for example: