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

tengo que hacer una consulta y necesito que el campo y el campo que se van a compara en el WHERE sean los datos que me manda de un fotmulari y despues mandarlos un mysql_fetch_array para poderlos exportar en exel.

si ago la consulta poniendo manualmente los datos me exporta perfectamente todo pero al poner la variable me manda este error ( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Proyecto3\Web\consulta.php on line 52



Código PHP:
<?php
//insertamos los headers que van a generar el archivo excel
header('Content-type: application/vnd.ms-excel');
//en filename vamos a colocar el nombre con el que el archivo xls sera generado
header("Content-Disposition: attachment; filename=consulta.xls");
header("Pragma: no-cache");
header("Expires: 0?");
//recogemos la variable de fecha con la que limitaremos la cinsulta.

//hacemos la conexion al servidor MySql
$conexion mysql_connect ("localhost""root""");
 
mysql_select_db ("retrabajo"$conexion);
//realizamos la consulta
$tipo $_POST['tipo'];
$dato $_POST['dato'];
 
$query=mysql_query ("SELECT * FROM entrada WHERE=$dato");
  
?>
<!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=utf-8" />
<title>Reporte de cosulta</title>
</head>

<body><!-Vamos a crear una tabla que será impresa en el archivo excel->
<table width="600" border="0">

</table>
<!-creamos la tabla de el reporte con border 1 y los títulos->
<table width="641" border="1">
<tr>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Schedule</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estilo</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Serie</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Id Tx</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Linia</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Area</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>KVAS</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj opererador</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj reparador</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Tipo de falla</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Codigo de falla</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fase</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha de entrada</strong></th>
<th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios</strong></th>
</tr>
<?php
// Un proceso repetitivo para imprimir cada uno de los registros.
while($row mysql_fetch_array($query)){
echo 
"<tr>
<td bgcolor=\"#ededed\" align=\"center\">$row[schedule]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[estilo]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[serie]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[idtx]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[linea]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[area]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[kvas]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[nrelojo]</td
<td bgcolor=\"#ededed\" align=\"center\">$row[nrelojr]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[falla]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[codigo]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[fase]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[fecha]</td>
<td bgcolor=\"#ededed\" align=\"center\">$row[comentarioe]</td>
</tr>"
;
}
?>
</table>
</table>
</body>
</html>