Ver Mensaje Individual
  #5 (permalink)  
Antiguo 28/12/2008, 12:54
--eDDu--
 
Fecha de Ingreso: diciembre-2007
Ubicación: Guatemala
Mensajes: 13
Antigüedad: 16 años, 4 meses
Puntos: 0
Respuesta: como pasar datos de una base de datos a un archivo excel

Que raro, te voy a poner un ejemplo aunque lo ideal seria que pusieras tu codigo y revisarlo para detectar el posible error, yo use una tabla para mostrar mi consulta.



Código PHP:

<?php
header
("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=Entidad.xls");

include_once(
"../connect.inc.php");
administrador($tipousuario);    

?>
<!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><?php echo $titulo_pagina?></title>
</head>
<body>

    <tr>
         <td><table width="99%" border="1" align="center" cellpadding="2" cellspacing="1" bordercolor="#000000" bgcolor="#FFFFFF" id="table4">

<tr bgcolor="#CCCCCC">
  <th width="22">&nbsp;</th>
    
    <th width="245" height="21"><div align="left"><span class="Estilo16">Entidad</span></div></th>
    <th width="81" class="Estilo16"><div align="right">Asignado</div></th>
    <th width="81" class="Estilo16"><div align="right">Modificado </div></th>
    <th width="81" class="Estilo16"><div align="right">Vigente</div></th>
    <th width="81" class="Estilo16"><div align="right">Devengado</div></th>
   </tr>
<?

$query5
="SELECT id_entidad, SUM(asignado) as tasignado, SUM(modificado) as tmodificado, SUM(vigente) as tvigente, SUM(devengado) as tdevengado FROM eys_ent_pro_ubg_actob_grup WHERE fecha_session='".$_SESSION['fecha']."' GROUP BY id_entidad";
$result5=mysql_query($query5);
while (
$row5=mysql_fetch_array($result5))
{

        
$eddu3 "SELECT nombre FROM eys_entidad WHERE id_entidad like '%".$row5["id_entidad"]."%'";
        
$eddu33 mysql_query($eddu3);
        
$jos3 mysql_fetch_array($eddu33);
        
    
        echo 
'<tr><td><span class="Estilo14">'.$row5["id_entidad"].'</center></td>';
        echo 
'<td><span class="Estilo14"><div align="left">'.$jos3["nombre"].'</div></td>';
        echo 
'<td><span class="Estilo14"><div align="right">'.$row5["tasignado"].'</div></td>';
        echo 
'<td><span class="Estilo14"><div align="right">'.$row5["tmodificado"].'</div></td>';
        echo 
'<td><span class="Estilo14"><div align="right">'.$row5["tvigente"].'</div></td>';
        echo 
'<td><span class="Estilo14"><div align="right">'.$row5["tdevengado"].'</div></td>';
                    
}
mysql_free_result($result5)
?>

</table>
</body>
</html>