elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Descargar Excel en php
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Descargar Excel en php  (Leído 1,182 veces)
tomasvreal28

Desconectado Desconectado

Mensajes: 12


Ver Perfil
Descargar Excel en php
« en: 12 Diciembre 2015, 02:52 am »

Buenas estoy tratando de descargar a excel
 pero necesito que a la hora de descargar se registre la fecha y se cambie el estado 5 al 6
de todos los registros que descargo


Código
  1.  
  2.  
  3. <?php
  4.  
  5. require_once('conexion.php');
  6.    header ("Cache-Control: no-cache, must-revalidate");  
  7.    header ("Pragma: no-cache");  
  8.    header ("Content-Type: application/vnd.ms-excel");
  9.    header ("Content-Disposition: attachment; filename=reporte.xls" );
  10.  
  11. $sql="select * from tbldocumentosicr INNER JOIN tblinfracciones ON tbldocumentosicr.icr_infraccion=tblinfracciones.icr_infraccion where icr_estado='5' order by icr_fecha_ri ASC";
  12.  
  13. $reg=mysql_query($sql,$cnx);
  14. ?>
  15. <table width="100%"  align="center" cellspacing="0">
  16. <tr><td colspan="12"  width="25" align=center><h5>TITULO</h5></td></tr>
  17. <tr><td colspan="12" width="90" align=center><h5>TITULO </h5></td></tr>
  18. <tr><td colspan="12" width="150" align=center><h5>TITULO PERIODO:</h5></td></tr>
  19.  
  20. </table>
  21. <table width="100%"  BORDER=3  align="center" cellspacing="0" BORDERCOLOR="#939393" BGCOLOR="FFFFFF">
  22.  
  23. <tr>
  24. <td width="25" align=center valign="top" BGCOLOR="C1D4D6"><h5>Nª</h5></td>
  25. <td width="90" align=center valign="top" BGCOLOR="C1D4D6"><h5>DEPENDENCIA</h5></td>
  26. <td width="85" align=center valign="top" BGCOLOR="C1D4D6"><b><h5>CODIGO</h5></b></td>
  27. <td width="150" align=center valign="top" BGCOLOR="C1D4D6"><h5>N CUENTA</h5></td>
  28. <td width="230" align=center valign="top" BGCOLOR="C1D4D6"><h5>NOMBRE</h5></td>
  29. <td width="100" align=center valign="top" BGCOLOR="C1D4D6"><h5>CODIGO RESLUCION</h5></td>
  30. <td width="100" align=center valign="top" BGCOLOR="C1D4D6"><h5>FECHA NOTIFICACION</h5></td>
  31. <td width="450" align=center valign="top" BGCOLOR="C1D4D6"><h5>CAUSAL DE INGRESO DE RECAUDACION</h5></td>
  32. <td width="100" align=center valign="top" BGCOLOR="C1D4D6"><h5>TIPO MONTO A TRASLADAR</h5></td>
  33. <td width="90" align=center valign="top" BGCOLOR="C1D4D6"><h5>OBSERVACIONES</h5></td>
  34. <td width="90" align=center valign="top" BGCOLOR="C1D4D6"><h5>PERIODOS DE REVISION</h5></td>
  35. <td width="90" align=center valign="top" BGCOLOR="C1D4D6"><h5>MONTO A TRASLADAR</h5></td>
  36. </tr>
  37. <?php
  38. $i=0;
  39. while($res=mysql_fetch_array($reg)){
  40. ?>
  41. <td width="25" align=center><h5><?php echo $i+1;?></h5></td>
  42. <td width="90"><h5>00<?php echo $res['icr_dependencia'];?></h5></td>
  43. <td width="85" align=center><h5><?php echo $res['icr_codigo'];?></h5></td>
  44. <td width="150"><h5><?php echo $res['icr_cuenta_bn'];?></h5></td>
  45. <td width="230" align=justify><h6><?php echo $res['icr_nombre'];?></h6></td>
  46. <td width="100" align=center><h5>0<?php echo $res['icr_dependencia'];?>024000<?php echo $res['icr_num_resolucion'];?></h5></td>
  47. <td width="100" align=center><h5><?php echo $res['icr_fecha_ri'];?></h5></td>
  48. <td width="450" align=justify><h5><?php echo $res['icr_causal'];?></h5></td>
  49.  
  50.    <td width="90" align=center>
  51.  <h5>
  52.    <?php if($res["icr_traslado"]==1){?> Saldo Parcial
  53.    <?php }elseif($res["icr_traslado"]==2){?> Saldo Total
  54.    <?php }?>    
  55.        </h5></td>
  56. <td width="90" align=justify><h6><?php echo $res['icr_observaciones_a'];?></h6></td>
  57.  
  58. <td width="90" align=center>
  59. <?php
  60. date_default_timezone_set('America/Lima');  
  61. $calendario_meses = array(
  62.    'January'=>'Enero',
  63.    'Febuary'=>'Febrero',
  64.    'March'=>'Marzo',
  65.    'April'=>'Abril',
  66.    'May'=>'Mayo',
  67.    'June'=>'Junio',
  68.    'July'=>'Julio',
  69.    'August'=>'Agosto',
  70.    'September'=>'Septiembre',
  71.    'October'=>'Octubre',
  72.    'November'=>'Noviembre',
  73.    'December'=>'Diciembre'
  74. );  
  75.  
  76. $data1 = explode('-', $res['icr_fecha_revision1']);  
  77. $fecha1 = date('F \d\e\l Y', strtotime($data1[0] . '-' . $data1[1]));
  78. $fecha1 = strtr($fecha1, $calendario_meses);
  79.  
  80. echo $fecha1; ?>  -
  81.  
  82. <?php
  83. date_default_timezone_set('America/Lima');  
  84. $calendario_meses2 = array(
  85.    'January'=>'Enero',
  86.    'Febuary'=>'Febrero',
  87.    'March'=>'Marzo',
  88.    'April'=>'Abril',
  89.    'May'=>'Mayo',
  90.    'June'=>'Junio',
  91.    'July'=>'Julio',
  92.    'August'=>'Agosto',
  93.    'September'=>'Septiembre',
  94.    'October'=>'Octubre',
  95.    'November'=>'Noviembre',
  96.    'December'=>'Diciembre'
  97. );  
  98.  
  99. $data2 = explode('-', $res['icr_fecha_revision2']);  
  100. $fecha2 = date('F \d\e\l Y', strtotime($data2[0] . '-' . $data2[1]));
  101. $fecha2 = strtr($fecha2, $calendario_meses2);
  102. echo $fecha2; ?>
  103. </td>
  104. <td width="90" align=center><h5><?php echo $res['icr_monto_icr'];?></h5></td>
  105. </tr>
  106.    <?php
  107. $i=$i+1;
  108. }
  109. ?>
  110. </table>
  111. </body>
  112. </html>
  113.  


En línea

_Zume

Desconectado Desconectado

Mensajes: 21



Ver Perfil
Re: Descargar Excel en php
« Respuesta #1 en: 19 Diciembre 2015, 08:47 am »

si tienes una PK en la tabla puedes hacerlo fácil:

Código
  1. UPDATE tbldocumentosicr SET icr_estado = '6' WHERE pID = ' . $res['id'] . '

y envias esa consulta, obviamente que $res['id'] deberia de ser remplazado por el nombre de la PK que cargas


« Última modificación: 21 Diciembre 2015, 14:32 pm por #!drvy » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines