Foros del Web » Programando para Internet » PHP »

Exportar dos documentos en Excel al mismo tiempo

Estas en el tema de Exportar dos documentos en Excel al mismo tiempo en el foro de PHP en Foros del Web. Buenas tardes a todos. Tengo el siguiente código que realiza una consulta que me arroja "n" valores estos valores se controlan con un ciclo, el ...
  #1 (permalink)  
Antiguo 16/07/2015, 12:24
 
Fecha de Ingreso: febrero-2015
Ubicación: Mexico
Mensajes: 1
Antigüedad: 9 años, 2 meses
Puntos: 0
Pregunta Exportar dos documentos en Excel al mismo tiempo

Buenas tardes a todos.

Tengo el siguiente código que realiza una consulta que me arroja "n" valores estos valores se controlan con un ciclo, el cual el resultado lo asigno a una segunda consulta la cual me genera un archivo de Excel.

El detalle que tengo es que solamente me genera un solo archivo de Excel y no varios dependiendo la primera consulta.

Alguien me prodria ayudar porfavor.

$qery_dlv = "SELECT DISTINCT Delivery_Number FROM dlv_envios WHERE Loading = '$temp'";
$temp_dlv =mysql_query($qery_dlv,$cnn) or die ("Error al consultar usuario <br>".mysql_error());

while ($row = mysql_fetch_array($temp_dlv, MYSQL_BOTH))
{
$temp2 =$row["Delivery_Number"];

$q= "SELECT DLV.Customer AS Customer,DLV.Delivery_Number AS DELIVERY_NUMBER,DLV.CC_Number AS CC_NUMBER,
DLV.Customer_Code AS CUSTOMER_CODE,DLV.INSPEC AS INSPEC,DLV.PART_NUMBER AS PART_NUMBER,DLV.SPEC AS SPEC,DLV.TRADE_CLS AS TRADE_CLS,
DLV.THICK AS THICKK,DLV.WIDTH AS WIDTH,DLV.Length AS LENGTH,DLV.WEIGHT AS WEIGHT,DLV.PCS AS PCS,DLV.MAKER_CD AS MAKER_CD,
DLV.CUT_NUMBER AS CUT_NUMBER, EQV.CUST_PART_NUMBER AS PART_CUST_NUMBER,DLV. COATING_CD AS COATING_CD,
DLV.SKID AS SKID,DLV.SERIAL_NO AS SERIAL,DLV.DELIVERY_DATE AS DELIVERY_DATE,DLV.DELIVERY_PLACE AS DELIVERY_PLACE
FROM dlv_envios as DLV left join equivalencias as EQV on DLV.Part_Number = EQV.part_number WHERE Loading ='$temp' AND Delivery_Number ='$temp2'";
$stid=mysql_query($q,$cnn) or die ("Error al consultar usuario <br>".mysql_error());

//$datosusuario=mysql_fetch_assoc($stid);
$datosusuario = mysql_fetch_array($stid,MYSQL_BOTH);
$filas=mysql_num_rows($stid);

if ($filas <= 0){
header ("Location:Location:error.php");
}
//if($row = mysql_fetch_array($delivery)){
// $test =$row["Delivery_Number"];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Export to XLS</title>
</head>
<body>
<p>&nbsp;</p>
<table width="80%" border="1" bordercolor="21a9b6">
<tr>
<td colspan="1" bgcolor="#16365c" style="color:#FFF;" ><b><?php echo 'Remisión -- '.$temp2 ?></b></td>
</tr>
<tr>
<td bgcolor="#16365c" style="color:#FFF"><b># Registro</b></td>
<?php
for ($i=0; $i < mysql_num_fields($stid); $i++){
?>
<td width="32%" bgcolor="#16365c" style="color:#FFF"><b><?php echo mysql_field_name($stid, $i); }?></b></td>
</tr>
<?php
$numero=0;
do
{
$numero += 1;
?>
<tr>
<td><?php echo $numero ; ?></td>
<?php for ($i=0; $i < mysql_num_fields($stid); $i++) { ?>
<td><?php
echo $datosusuario[$i];
?></td>
<?php }?>
</tr>
<?php }while ($datosusuario = mysql_fetch_array($stid,MYSQL_BOTH));?>
</table>
</body>
</html>
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-disposition:attachment;filename=$temp2.xls");
header("Connection:close");
}

Etiquetas: documentos, excel, html, mysql, registro, select, sql, tiempo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:52.