I have 2 Querys generated one that is from clients and another from suppliers. They are both different Querys.
But when you download them to a flat file, I join them in the same file, but they are separated by the clients and providers , just as I show in the following example.
***CLIENTES
10109473! !GUSTAVO ALBERTO SANINT ALARCON ! ! ! !CLL 38A N 80-53! !2505812 !3162551326 !05001 !ANTIOQUIA !MEDELLIN !
1037574963! !JANET VIVIANA ALVAREZ ! ! ! !CRA115A N 34B -44! !3122042727 ! !05001 !ANTIOQUIA !MEDELLIN !
1045106908! !VIVIANSY ZAPATA !N!N!N!CARRERA 45 # 30 - 66! !2623042 ! !05001 !ANTIOQUIA !MEDELLIN !
***PROVEEDORES
1128277849! !PLACAS SAN DIEGO ESTEBAN ALONSO SANCHEZ G. !N!N!N!CARRERA 45 37-78! !3812789 !3812789 !05001 !ANTIOQUIA !MEDELLIN !
1128422428! !JUANITA ARROYAVE GAVIRIA !N!N!N!CRA 30 # 7A-167! !3541058 ! !05001 !ANTIOQUIA !MEDELLIN !
These are the syntax of both queries:
$sql=" select
CASE WHEN x0.sw_persona_juridica=1 THEN
SUBSTRING(cast( x0.cedula as varchar(20)) FROM 1 FOR 9) ELSE cast(x0.cedula as varchar(20)) END nit ,
CASE WHEN x0.sw_persona_juridica=1 THEN
SUBSTRING(cast( x0.cedula as varchar(20)) FROM 9 FOR 2) ELSE '' END dv,
x0.nombres ,x0.apellidos,x0.telefono,x0.celular as tel_alterno,
x0.dir_cliente,x1.c_ciudad as cod_ciudad,x2.d_departamento as departamento,
x1.d_ciudad as ciudad,x0.sw_persona_juridica as tipo_tercero,x0.email,
c_doc_cliente as tipo_doc,x0.id_alterno_cliente,x0.sw_regimen_comun,
x0.sw_regimen_simplificado,x0.sw_gran_contribuyente
FROM m_clientes x0 ,m_ciudades_mahalo x1,m_departamentos_mahalo x2
WHERE x0.c_ciudad=x1.c_ciudad
AND x1.c_departamento=x2.c_departamento
$rangoFechas ;";
p_query($sql);
//echo "<br><br>--30--<br>".$sql;
$vectorDeConsultas[$idxDeConsultas] = $sql;
$idxDeConsultas = $idxDeConsultas + 1;
/*$sql1=" select x0.nit nit2,x0.digito_verifica dv2,x0.d_proveedor,x0.direccion dir2,x0.telefono tel2,
x0.telefono as tel_alterno2 ,e_mail as e_mail2,x1.c_ciudad as cod_ciudad2,
x2.d_departamento as departamento2,x1.d_ciudad as ciudad2
FROM m_proveedores x0 ,m_ciudades_mahalo x1,m_departamentos_mahalo x2
WHERE x0.c_ciudad=x1.c_ciudad
AND x1.c_departamento=x2.c_departamento;";
//$rangoFechas ;";
p_query($sql1);
//echo "<br><br>--30--<br>".$sql;
$vectorDeConsultas[$idxDeConsultas] = $sql1;
$idxDeConsultas = $idxDeConsultas + 1;
Mediate a While after generating the query. I take a tour and assign each variable its respective values example:
$nit=round(trim($registro['nit']),0);
$DV=trim($registro['dv']); .
I end up filling an Array with this information:
$ArrayPlanoTERCEROACTIVO[$j][1]=$nit;//NIT (SIN PUNTOS, COMAS NI DIGITO DE VERIFICACIÓN)
$linea2 = $linea2.str_pad($ArrayPlanoTERCEROACTIVO[$j][1], 13).$separador;
$ArrayPlanoTERCEROACTIVO[$j][2]=$DV;//DV (DIGITO DE VERIFICACIÓN)
$linea2 = $linea2.str_pad($ArrayPlanoTERCEROACTIVO[$j][2], 1).$separador;
fwrite($ff, $linea2);
In this case I only paint the customer information but without the header
I need that in the same file they load the information of both consultations separated by the headings previously mentioned