Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/11/2015, 13:46
edgaralcalaserra
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 7 meses
Puntos: 1
Respuesta: consulta con variables

esta es la forma que funciona
Código PHP:
Ver original
  1. <?php
  2. //insertamos los headers que van a generar el archivo excel
  3. header('Content-type: application/vnd.ms-excel');
  4. //en filename vamos a colocar el nombre con el que el archivo xls sera generado
  5. header("Content-Disposition: attachment; filename=consulta.xls");
  6. header("Pragma: no-cache");
  7. header("Expires: 0?");
  8. //recogemos la variable de fecha con la que limitaremos la cinsulta.
  9.  
  10. //hacemos la conexion al servidor MySql
  11. $conexion = mysql_connect ("localhost", "root", "");
  12.  mysql_select_db ("retrabajo", $conexion);
  13. //realizamos la consulta
  14. $tipo = $_POST['tipo'];
  15. $dato = $_POST['dato'];
  16.  $query=mysql_query ("SELECT * FROM entrada WHERE estilo='esteesmidato'");
  17. ?>
  18. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  19. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  20. <html xmlns="http://www.w3.org/1999/xhtml">
  21. <head>
  22. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  23. <title>Reporte de cosulta</title>
  24. </head>
  25.  
  26. <body><!-Vamos a crear una tabla que será impresa en el archivo excel->
  27.  
  28. <!-creamos la tabla de el reporte con border 1 y los títulos->
  29. <table width="641" border="1">
  30. <tr>
  31. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Schedule</strong></th>
  32. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estilo</strong></th>
  33. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Serie</strong></th>
  34. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Id Tx</strong></th>
  35. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Linia</strong></th>
  36. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Area</strong></th>
  37. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>KVAS</strong></th>
  38. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj opererador</strong></th>
  39. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj reparador</strong></th>
  40. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Tipo de falla</strong></th>
  41. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Codigo de falla</strong></th>
  42. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fase</strong></th>
  43. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha de entrada</strong></th>
  44. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios</strong></th>
  45. </tr>
  46. <?php
  47. // Un proceso repetitivo para imprimir cada uno de los registros.
  48. while($row = mysql_fetch_array($query)){
  49. echo
  50. "<tr>
  51. <td bgcolor=\"#ededed\" align=\"center\">$row[schedule]</td>
  52. <td bgcolor=\"#ededed\" align=\"center\">$row[estilo]</td>
  53. <td bgcolor=\"#ededed\" align=\"center\">$row[serie]</td>
  54. <td bgcolor=\"#ededed\" align=\"center\">$row[idtx]</td>
  55. <td bgcolor=\"#ededed\" align=\"center\">$row[linea]</td>
  56. <td bgcolor=\"#ededed\" align=\"center\">$row[area]</td>
  57. <td bgcolor=\"#ededed\" align=\"center\">$row[kvas]</td>
  58. <td bgcolor=\"#ededed\" align=\"center\">$row[nrelojo]</td
  59. <td bgcolor=\"#ededed\" align=\"center\">$row[nrelojr]</td>
  60. <td bgcolor=\"#ededed\" align=\"center\">$row[falla]</td>
  61. <td bgcolor=\"#ededed\" align=\"center\">$row[codigo]</td>
  62. <td bgcolor=\"#ededed\" align=\"center\">$row[fase]</td>
  63. <td bgcolor=\"#ededed\" align=\"center\">$row[fecha]</td>
  64. <td bgcolor=\"#ededed\" align=\"center\">$row[comentarioe]</td>
  65. </tr>";
  66. }
  67. ?>
  68. </table>
  69. </table>
  70. </body>
  71. </html>

y esta es la forma que quiero que quede
Código PHP:
Ver original
  1. <?php
  2. //insertamos los headers que van a generar el archivo excel
  3. header('Content-type: application/vnd.ms-excel');
  4. //en filename vamos a colocar el nombre con el que el archivo xls sera generado
  5. header("Content-Disposition: attachment; filename=consulta.xls");
  6. header("Pragma: no-cache");
  7. header("Expires: 0?");
  8. //recogemos la variable de fecha con la que limitaremos la cinsulta.
  9.  
  10. //hacemos la conexion al servidor MySql
  11. $conexion = mysql_connect ("localhost", "root", "");
  12.  mysql_select_db ("retrabajo", $conexion);
  13. //realizamos la consulta
  14. $tipo = $_POST['tipo'];
  15. $dato = $_POST['dato'];
  16.  $query=mysql_query ("SELECT * FROM entrada WHERE $tipo=$dato");
  17.  
  18. ?>
  19. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  20. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  21. <html xmlns="http://www.w3.org/1999/xhtml">
  22. <head>
  23. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  24. <title>Reporte de cosulta</title>
  25. </head>
  26.  
  27. <body><!-Vamos a crear una tabla que será impresa en el archivo excel->
  28.  
  29. <!-creamos la tabla de el reporte con border 1 y los títulos->
  30. <table width="641" border="1">
  31. <tr>
  32. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Schedule</strong></th>
  33. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estilo</strong></th>
  34. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Serie</strong></th>
  35. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Id Tx</strong></th>
  36. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Linia</strong></th>
  37. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Area</strong></th>
  38. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>KVAS</strong></th>
  39. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj opererador</strong></th>
  40. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj reparador</strong></th>
  41. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Tipo de falla</strong></th>
  42. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Codigo de falla</strong></th>
  43. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fase</strong></th>
  44. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha de entrada</strong></th>
  45. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios</strong></th>
  46. </tr>
  47. <?php
  48. // Un proceso repetitivo para imprimir cada uno de los registros.
  49. while($row = mysql_fetch_array($query)){
  50. echo
  51. "<tr>
  52. <td bgcolor=\"#ededed\" align=\"center\">$row[schedule]</td>
  53. <td bgcolor=\"#ededed\" align=\"center\">$row[estilo]</td>
  54. <td bgcolor=\"#ededed\" align=\"center\">$row[serie]</td>
  55. <td bgcolor=\"#ededed\" align=\"center\">$row[idtx]</td>
  56. <td bgcolor=\"#ededed\" align=\"center\">$row[linea]</td>
  57. <td bgcolor=\"#ededed\" align=\"center\">$row[area]</td>
  58. <td bgcolor=\"#ededed\" align=\"center\">$row[kvas]</td>
  59. <td bgcolor=\"#ededed\" align=\"center\">$row[nrelojo]</td
  60. <td bgcolor=\"#ededed\" align=\"center\">$row[nrelojr]</td>
  61. <td bgcolor=\"#ededed\" align=\"center\">$row[falla]</td>
  62. <td bgcolor=\"#ededed\" align=\"center\">$row[codigo]</td>
  63. <td bgcolor=\"#ededed\" align=\"center\">$row[fase]</td>
  64. <td bgcolor=\"#ededed\" align=\"center\">$row[fecha]</td>
  65. <td bgcolor=\"#ededed\" align=\"center\">$row[comentarioe]</td>
  66. </tr>";
  67. }
  68. ?>
  69. </table>
  70. </table>
  71. </body>
  72. </html>