Foros del Web » Programando para Internet » PHP »

consulta con where

Estas en el tema de consulta con where en el foro de PHP en Foros del Web. señores necesito de su ayuda tengo esta consulta @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: Ver original $conexion = mysql_connect ( "localhost" , "root" , "" ) ; ...
  #1 (permalink)  
Antiguo 23/11/2015, 13:22
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Sonrisa consulta con where

señores necesito de su ayuda

tengo esta consulta
Código PHP:
Ver original
  1. $conexion = mysql_connect ("localhost", "root","");
  2.  mysql_select_db ("eaton", $conexion);
  3.  
  4.  
  5. $query=mysql_query ("SELECT * FROM info,embobinado ");
  6.  
  7. ?>

y me funciona bien pero el problema es cuando lo ago de esta manera

Código PHP:
Ver original
  1. $conexion = mysql_connect ("localhost", "root","");
  2.  mysql_select_db ("eaton", $conexion);
  3.  
  4.  
  5. $query=mysql_query ("SELECT * FROM info,embobinado WHERE (schedule='S750000')");
  6.  
  7. ?>
  #2 (permalink)  
Antiguo 23/11/2015, 13:24
Avatar de chronos682  
Fecha de Ingreso: febrero-2004
Ubicación: Tunja - Boyacá - Colombia
Mensajes: 627
Antigüedad: 20 años, 2 meses
Puntos: 69
Respuesta: consulta con where

Qué error te sale? Ya probaste quitando los paréntesis del where?
__________________
Si te gustó la respuesta dale +1

HERNÁN G. SIABATO M.
[email protected]
  #3 (permalink)  
Antiguo 23/11/2015, 13:27
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

ya probe sin parentesis y es es el erroe que sale

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Web\reportes.php on line 51


la linea 51 es

Código PHP:
Ver original
  1. while($row = mysql_fetch_array($query))
  #4 (permalink)  
Antiguo 23/11/2015, 13:29
Avatar de chronos682  
Fecha de Ingreso: febrero-2004
Ubicación: Tunja - Boyacá - Colombia
Mensajes: 627
Antigüedad: 20 años, 2 meses
Puntos: 69
Respuesta: consulta con where

Coloca todo el código para verlo en conjunto.
__________________
Si te gustó la respuesta dale +1

HERNÁN G. SIABATO M.
[email protected]
  #5 (permalink)  
Antiguo 23/11/2015, 13:34
Avatar de xfxstudios  
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 9 meses
Puntos: 263
Respuesta: consulta con where

ok el problema es si te esta trayendo datos y si el array esta condicionado en caso de que no, es decir:

Código PHP:
Ver original
  1. if($total <= 0){
  2. echo "No hay datos";
  3. }else{
  4. while($row = $cosa->fetch_array()){
  5. //aqui el resto
  6. }
__________________
[email protected]
HITCEL
  #6 (permalink)  
Antiguo 23/11/2015, 13:35
Avatar de xfxstudios  
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 9 meses
Puntos: 263
Respuesta: consulta con where

por cierto utiliza mejor mysqli para tus querys y conexiones, mysql ya no tiene mas soporte
__________________
[email protected]
HITCEL
  #7 (permalink)  
Antiguo 23/11/2015, 13:37
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

este codigo lo utilizo en otra consulta y me funciona bien ahora quiero adecuarlo a este codigo

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 ("eaton", $conexion);
  13. //realizamos la consulta
  14. //$tipo = $_POST['tipo'];
  15. //$dato = $_POST['dato'];
  16. //$inicio = $_POST['inicio'];
  17. //$final = $_POST['final'];
  18.  
  19. $query=mysql_query ("SELECT * FROM info,embobinado WHERE schedule='S750000'");
  20.  
  21. ?>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  23. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <body><!-Vamos a crear una tabla que será impresa en el archivo excel->
  26.  
  27. <!-creamos la tabla de el reporte con border 1 y los títulos->
  28. <table width="641" border="1">
  29. <tr>
  30.  
  31. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estilo</strong></th>
  32. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Serie</strong></th>
  33. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Id TX</strong></th>
  34. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Linea</strong></th>
  35. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Area</strong></th>
  36. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>KVA'S</strong></th>
  37. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj del operador</strong></th>
  38. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj del reparador</strong></th>
  39. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Falla</strong></th>
  40. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Codigo</strong></th>
  41. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fase</strong></th>
  42. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha entrada</strong></th>
  43. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios entrada</strong></th>
  44. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus</strong></th>
  45. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha salida</strong></th>
  46. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios salida</strong></th>
  47. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios </strong></th>
  48. </tr>
  49. <?php
  50. // Un proceso repetitivo para imprimir cada uno de los registros.
  51. while($row = mysql_fetch_array($query)){
  52. echo
  53. "<tr>
  54. <td bgcolor=\"#ededed\" align=\"center\">$row[suffix]</td>
  55. <td bgcolor=\"#ededed\" align=\"center\">$row[order]</td>
  56. <td bgcolor=\"#ededed\" align=\"center\">$row[item]</td>
  57. <td bgcolor=\"#ededed\" align=\"center\">$row[co]</td>
  58. <td bgcolor=\"#ededed\" align=\"center\">$row[responsible]</td>
  59. <td bgcolor=\"#ededed\" align=\"center\">$row[statusemb]</td>
  60. <td bgcolor=\"#ededed\" align=\"center\">$row[fechaemb]<td>
  61.  
  62. </tr>";
  63. }
  64. ?>
  65. </table>
  66. </table>
  67. </body>
  68. </html>
  #8 (permalink)  
Antiguo 23/11/2015, 13:39
Avatar de chronos682  
Fecha de Ingreso: febrero-2004
Ubicación: Tunja - Boyacá - Colombia
Mensajes: 627
Antigüedad: 20 años, 2 meses
Puntos: 69
Respuesta: consulta con where

Copia y pega esto SELECT * FROM info,embobinado WHERE schedule='S750000' en phpmyadmin y comentas si te devuelve algún resultado.
__________________
Si te gustó la respuesta dale +1

HERNÁN G. SIABATO M.
[email protected]
  #9 (permalink)  
Antiguo 23/11/2015, 13:49
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

me funciona por separado si lo ago junto me da est error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''embobinado' WHERE `schedule`= 's750000' LIMIT 0, 30' at line 1
  #10 (permalink)  
Antiguo 23/11/2015, 13:54
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

SELECT * FROM `embobinado` WHERE `schedule`='s750000'
SELECT * FROM `info` WHERE `schedule`='s750000'
  #11 (permalink)  
Antiguo 23/11/2015, 13:58
Avatar de Perr0  
Fecha de Ingreso: mayo-2005
Ubicación: Santiago de Chile, Chile
Mensajes: 676
Antigüedad: 18 años, 10 meses
Puntos: 79
Respuesta: consulta con where

Coloca lo siguiente antes de la línea 51

Código PHP:
Ver original
  1. print $query;exit;

luego copia el texto y lo pegas en phpmyadmin o el gestor de base que tengas?
si tienes un error en el código, será mas precisa la información por el gestor.


salu2
__________________
Numerador Mp3 en Access =)
http://www.mediafire.com/download/r9...pdw/mp3(2).zip
  #12 (permalink)  
Antiguo 23/11/2015, 14:06
Avatar de chronos682  
Fecha de Ingreso: febrero-2004
Ubicación: Tunja - Boyacá - Colombia
Mensajes: 627
Antigüedad: 20 años, 2 meses
Puntos: 69
Respuesta: consulta con where

Obvio, no me había dado cuenta, tienes que hacer los querys por separado, uno para cada tabla.
__________________
Si te gustó la respuesta dale +1

HERNÁN G. SIABATO M.
[email protected]
  #13 (permalink)  
Antiguo 23/11/2015, 14:06
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

ya no me sale el error pero no me da ningun dato en la consulta
  #14 (permalink)  
Antiguo 23/11/2015, 14:07
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

no se puede hacer una sola consulta???
  #15 (permalink)  
Antiguo 23/11/2015, 14:10
Avatar de chronos682  
Fecha de Ingreso: febrero-2004
Ubicación: Tunja - Boyacá - Colombia
Mensajes: 627
Antigüedad: 20 años, 2 meses
Puntos: 69
Respuesta: consulta con where

No, porque son dos tablas diferentes, si necesitas que se muestren los datos de ambas tablas tienes que usar UNION, revisa esto o INNER JOIN.
__________________
Si te gustó la respuesta dale +1

HERNÁN G. SIABATO M.
[email protected]

Última edición por chronos682; 23/11/2015 a las 14:33
  #16 (permalink)  
Antiguo 23/11/2015, 14:59
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

pero el INNER JOIN es para comparar campos de dos tablas y yo lo que necesito que me de los datos de dos tablas donde el dato sea el que yo asigne
  #17 (permalink)  
Antiguo 23/11/2015, 15:39
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: consulta con where

Saludo.
En ese caso puede ser con UNION, como ya lo comentaron,
y sí la memoria no me falla, al hacer una consulta de unión
se tiene que traer la misma cantidad de campos,
es decir, que el select * tal vez no funcione pues una tabla
puede tener más o menos campos que otras
(y por cierto, hacer consultas con el * sí bien nos deja disponibles
todos los campos de las tablas, es malisima práctica pues
afectará el rendimiento).
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #18 (permalink)  
Antiguo 23/11/2015, 15:45
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

me funciono des esta manera pero tengo un problema

las tablas son de un preceso de produccion y el producto puede ser que apenas este en el primer preceso y por lo tanto en la siguiente tabla estara vacio los datos si, el problema es que si en la tabla core coil no hay datos al momento de hacer la consulta no me da ningun dato

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 ("eaton", $conexion);
  13. //realizamos la consulta
  14. //$tipo = $_POST['tipo'];
  15. //$dato = $_POST['dato'];
  16. //$inicio = $_POST['inicio'];
  17. //$final = $_POST['final'];
  18.  
  19. $query=mysql_query ("SELECT * FROM info WHERE schedule ='s750000'");
  20. $qye=mysql_query ("SELECT * FROM embobinado WHERE schedule ='s750000'");
  21. $qyes=mysql_query ("SELECT * FROM corecoil WHERE schedule ='s750000'");
  22.  
  23. ?>
  24. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  25. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  26. <html xmlns="http://www.w3.org/1999/xhtml">
  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.  
  33. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>suffix</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>Linea</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>KVA'S</strong></th>
  39. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj del operador</strong></th>
  40. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Numero de reloj del reparador</strong></th>
  41. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Falla</strong></th>
  42. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Codigo</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 entrada</strong></th>
  45. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios entrada</strong></th>
  46. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus</strong></th>
  47. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha salida</strong></th>
  48. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios salida</strong></th>
  49. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Comentarios </strong></th>
  50. </tr>
  51. <?php
  52. // Un proceso repetitivo para imprimir cada uno de los registros.
  53.  
  54. while($row = mysql_fetch_array($query))
  55. while($raw = mysql_fetch_array($qye))
  56. while($rew = mysql_fetch_array($qyes)){
  57. echo
  58. "<tr>
  59. <td bgcolor=\"#ededed\" align=\"center\">$row[suffix]</td>
  60. <td bgcolor=\"#ededed\" align=\"center\">$row[order]</td>
  61. <td bgcolor=\"#ededed\" align=\"center\">$row[item]</td>
  62. <td bgcolor=\"#ededed\" align=\"center\">$row[co]</td>
  63. <td bgcolor=\"#ededed\" align=\"center\">$row[responsible]</td>
  64. <td bgcolor=\"#ededed\" align=\"center\">$raw[statusemb]</td>
  65. <td bgcolor=\"#ededed\" align=\"center\">$raw[fechaemb]</td>
  66. <td bgcolor=\"#ededed\" align=\"center\">$rew[statuscore]</td>
  67. <td bgcolor=\"#ededed\" align=\"center\">$rew[fechacore]<td>
  68.  
  69. </tr>";
  70. }
  71. ?>
  72. </table>
  73. </table>
  74. </body>
  75. </html>
  #19 (permalink)  
Antiguo 23/11/2015, 16:09
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: consulta con where

Saludo.
En primera, no hay necesidad de hacer tres while.
Con asignar a cada variable el valor del fetch es suficiente.
y el echo se haría normal, no dentro de un while.

Por otra parte, obviamente sí no existe el registro
en alguna de las tablas, pues no traerá info!

Razón por la cual se puede usar un IF en cada td preguntando
sí el campo tiene valor, y si no lo tiene que muestre un mensaje
por defecto, algo como, producto aún no procesado, por ejemplo.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #20 (permalink)  
Antiguo 23/11/2015, 16:27
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

si quito los whiles me marca este error

Parse error: syntax error, unexpected '(' in C:\wamp\www\Web\reportes.php on line 56

Cita:
Por otra parte, obviamente sí no existe el registro
en alguna de las tablas, pues no traerá info!
los cuando digo que los datosn no me aparecen me refiero a los de las otras tablas

por ejemplo si en la tabla core coil no tengo datos tampoco me da los datos de la tabla info y de la tabla embobinado
  #21 (permalink)  
Antiguo 23/11/2015, 20:51
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: consulta con where

Saludo.
Pues como dije antes el echo ya no va dentro de un while,
entonces las llaves del while se tienen que ir también.

En cuanto a los datos, por eso sugerí un if en cada td,
para saber en realidad cuales datos sí vienen y cuales no.

Sin embargo, luego de hacer los respectivos fetch,
se podría hacer var_dump a cada variable para verificar
el contenido de las mismas.


__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #22 (permalink)  
Antiguo 24/11/2015, 08:00
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

me podrias dar un ejemplo del IF como quedaria o del var_dump

Última edición por edgaralcalaserra; 24/11/2015 a las 08:14
  #23 (permalink)  
Antiguo 24/11/2015, 08:57
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

ya funciono de esta manera

Código PHP:
Ver original
  1. ($row = mysql_fetch_array($query))
  2. ($raw = mysql_fetch_array($qye))
  3. ($rew = mysql_fetch_array($qyes)){
  4. echo
  #24 (permalink)  
Antiguo 24/11/2015, 13:06
 
Fecha de Ingreso: octubre-2015
Ubicación: ciudad juarez
Mensajes: 90
Antigüedad: 8 años, 6 meses
Puntos: 1
Respuesta: consulta con where

señores
ahora tengo otro problema al hacer la consulta solo me da una linea

no me da todos los datos

Código &quot:
Ver original
  1. ;
  2. //$dato = $_POST['dato'];
  3. //$inicio = $_POST['inicio'];
  4. //$final = $_POST['final'];
  5.  
  6. $query=mysql_query ("SELECT * FROM info WHERE schedule ='s750000'");
  7. $qye=mysql_query ("SELECT * FROM embobinado WHERE schedule ='s750000'");
  8. $qyes=mysql_query ("SELECT * FROM corecoil WHERE schedule ='s750000'");
  9. $qes=mysql_query ("SELECT * FROM preliminar WHERE schedule ='s750000'");
  10. $qesl=mysql_query ("SELECT * FROM oven WHERE schedule ='s750000'");
  11. $qesls=mysql_query ("SELECT * FROM final WHERE schedule ='s750000'");
  12. $qeslls=mysql_query ("SELECT * FROM empaque WHERE schedule ='s750000'");
  13.  
  14.  
  15. ?>
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  17. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  18. <html xmlns="http://www.w3.org/1999/xhtml">
  19. <body><!-Vamos a crear una tabla que será impresa en el archivo excel->
  20.  
  21. <!-creamos la tabla de el reporte con border 1 y los títulos->
  22. <table width="641" border="1">
  23. <tr>
  24.  
  25. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>suffix</strong></th>
  26. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Order</strong></th>
  27. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Item</strong></th>
  28. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>CO</strong></th>
  29. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Responsable</strong></th>
  30. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus Embobinado</strong></th>
  31. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha Embobinado</strong></th>
  32. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus Core Coil</strong></th>
  33. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha Core Coil</strong></th>
  34. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus Preliminar</strong></th>
  35. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha Preliminar</strong></th>
  36. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus Oven</strong></th>
  37. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha Oven</strong></th>
  38. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus Final</strong></th>
  39. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha Final</strong></th>
  40. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Estatus Empaque</strong></th>
  41. <th width="50%" style="background-color:#006; text-align:center; color:#FFF"><strong>Fecha Empaque</strong></th>
  42. </tr>
  43. <?php
  44. // Un proceso repetitivo para imprimir cada uno de los registros.
  45.  
  46. $row = mysql_fetch_array($query);
  47. $raw = mysql_fetch_array($qye);
  48. $rew = mysql_fetch_array($qyes);
  49. $riw = mysql_fetch_array($qes);
  50. $ruw = mysql_fetch_array($qesl);
  51. $ruws = mysql_fetch_array($qesls);
  52. $ruwo = mysql_fetch_array($qeslls);
  53.  
  54. echo
  55. "<tr>
  56. <td bgcolor=\"#ededed\" align=\"center\">$row[suffix]</td>
  57. <td bgcolor=\"#ededed\" align=\"center\">$row[order]</td>
  58. <td bgcolor=\"#ededed\" align=\"center\">$row[item]</td>
  59. <td bgcolor=\"#ededed\" align=\"center\">$row[co]</td>
  60. <td bgcolor=\"#ededed\" align=\"center\">$row[responsible]</td>
  61. <td bgcolor=\"#ededed\" align=\"center\">$raw[statusemb]</td>
  62. <td bgcolor=\"#ededed\" align=\"center\">$raw[fechaemb]</td>
  63. <td bgcolor=\"#ededed\" align=\"center\">$rew[statuscore]</td>
  64. <td bgcolor=\"#ededed\" align=\"center\">$rew[fechacore]</td>
  65. <td bgcolor=\"#ededed\" align=\"center\">$riw[statuspre]</td>
  66. <td bgcolor=\"#ededed\" align=\"center\">$riw[fechapre]</td>
  67. <td bgcolor=\"#ededed\" align=\"center\">$ruw[statusoven]</td>
  68. <td bgcolor=\"#ededed\" align=\"center\">$ruw[fechaoven]</td>
  69. <td bgcolor=\"#ededed\" align=\"center\">$ruws[statusfinal]</td>
  70. <td bgcolor=\"#ededed\" align=\"center\">$ruws[fechafinal]</td>
  71. <td bgcolor=\"#ededed\" align=\"center\">$ruwo[statusemp]</td>
  72. <td bgcolor=\"#ededed\" align=\"center\">$ruwo[fechaemp]</td>
  73. </tr>";
  74.  
  75. ?>
  76. </table>
  77. </table>
  78. </body>
  79. </html>]
  #25 (permalink)  
Antiguo 24/11/2015, 21:16
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: consulta con where

Saludo.

A ver, empecemos por los querys.
¿Cada uno de ellos devuelve un registro en la respectiva tabla,
o hay algunos que devuelvan màs de un registro?

Sí hubiese al menos uno que traiga varios, se tendría que volver
a la estructura del while con el fetch_array que traiga más datos.

Ej
Supongamos que info trae tres registros, preliminar dos, y el resto uno.
Así el asunto, el while se haría con info,
y se usarían variables para iterar sobre los demás,
es decir, por ej $i para preliminar, y para los demas $j.

$i y $j valdrían 0 antes del while, y una vez dentro se usarían, y $i se aumentaría en uno para que muestre el segundo registro al recorrer
los tres del while, obviamente, a consecuencia de esto se tendrían
tres registros con información duplicada para el caso de preliminar,
y triplicada para el resto.


__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com

Etiquetas: mysql, select, sql
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 14:15.