Ver Mensaje Individual
  #6 (permalink)  
Antiguo 02/10/2013, 10:03
medcol
 
Fecha de Ingreso: septiembre-2011
Mensajes: 32
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Generación de txt con php

esta es la estructura de lo que hay.



$sql2 = "SELECT DISTINCT p1.fecha, p1.numero,CONVERT(varchar(10),p1.fecha,103) as fechas, bo.IDCISA
FROM pedidosp AS p1
INNER JOIN pedidos AS p2 ON p1.numero = p2.numero
INNER JOIN bodegas AS bo ON p1.cc=bo.bodega
WHERE p1.nit='xxxxx'
AND p1.fecha = '$fecha'
ORDER BY p1.numero ASC";

$stmt2 = odbc_exec($conn, $sql2);
$row2 = odbc_fetch_array($stmt2);

$fechatitulo=date("Y-m-d-H-i-s");

$archivo = "file-".$fechatitulo.".txt";

do{

echo $cadena="A\t".substr(trim($row2['numero']),-4)."\tTA\t1000\t10\t10\t".trim($row2['IDCISA'])."\t100\t".trim($row2['numero'])."\t".trim(str_replace("/",".",$row2['fechas']))."\r\n";


}while($row2 = odbc_fetch_array($stmt2));

header("Content-disposition: attachment; filename=$archivo");
header("Content-type: application/octet-stream");
readfile($archivo);