Foros del Web » Programando para Internet » PHP »

Ayuda PHP consulta...

Estas en el tema de Ayuda PHP consulta... en el foro de PHP en Foros del Web. Hola, tengo el siguiente problema: lo que sucede es que tengo un combobox donde me despliega el nombre de los usuarios, ay dar clic y ...
  #1 (permalink)  
Antiguo 19/10/2010, 12:52
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Pregunta Ayuda PHP consulta...

Hola, tengo el siguiente problema: lo que sucede es que tengo un combobox donde me despliega el nombre de los usuarios, ay dar clic y darle aceptar al boton, debe arrojarme los datos de ese usuario.
Resulta que en la BD tengo dos datos de la misma persona, y solo me muestra un dato quiera me ayudaran a ver en que esta mi error....

//Este es el combobox que jala el nombre de los usuarios desde una tabla:

Código PHP:
Ver original
  1. <?php
  2. $CONEXION = mysql_connect("localhost","root","");
  3. if (!$CONEXION) {
  4.     die("p class='Estilo1' align='center'>LO SIENTO, PERO NO HA PODIDO CONECTARSE A MYSQL: </p>" . mysql_error());
  5.         }
  6.     else{
  7.         mysql_select_db("bd_control", $CONEXION);
  8.         $ARTICULOS=mysql_query("SELECT id_nom, nombre FROM usuarios ");
  9.         $ERROR = mysql_error($CONEXION);
  10.         if(empty($ERROR)){
  11.             echo "<select name=ART>";
  12.             echo "<option selected='' value=''> [ Seleccione ] </option>";
  13.             while ($ARTICULO=mysql_fetch_array($ARTICULOS)){
  14.             echo "<option value=".$ARTICULO["id_nom"].">".$ARTICULO["nombre"]."</option>";
  15.         }              
  16.         echo "</select>";
  17.         }
  18.         else{
  19.     $ERROR_CONSULTA="NO SE PUEDEN MOSTRAR LOS PRODUCTOS DEBIDO AL SIGUIENTE ERROR: ";
  20.         }
  21.     }
  22. ?>

//En esta parte es donde me jalo los datos de la BD...

<input type="submit" name="ACEPTAR" value="Aceptar" />
</form>

Código PHP:
Ver original
  1. <?php
  2. if (isset($_POST["ACEPTAR"])){
  3.     $ART=$_POST["ART"];
  4.     $ART_SEL=mysql_query
  5.     ("SELECT folio, fecha, hora, unidad, area, reporta, tel, ext, vpn, inventario,
  6.     serie, ip, marca, modelo, dispositivo, falla, nombre, actividades
  7.     FROM reporte, unidades, usuarios  
  8.     WHERE reporte.id_unidad=unidades.id_unidad
  9.     AND reporte.id_nom=usuarios.id_nom
  10.     AND reporte.id_nom=$ART");
  11.     $error=mysql_error($CONEXION); echo $error;
  12.     $fila=mysql_fetch_array($ART_SEL);
  13.     if(mysql_num_rows($ART_SEL)){
  14.         echo "<table width='800' border='1' align='center'>
  15.         <tr>
  16.             <th width='90' scope='col'>FOLIO</th>
  17.             <th width='66' scope='col'>FECHA</th>
  18.     <th width='65' scope='col'>HORA</th>
  19.     <th width='69' scope='col'>UNIDAD</th>
  20.     <th width='90' scope='col'>AREA</th>
  21.     <th width='66' scope='col'>REPORTA</th>
  22.     <th width='65' scope='col'>TEL</th>
  23.     <th width='69' scope='col'>EXT</th>
  24.     <th width='90' scope='col'>VPN</th>
  25.     <th width='66' scope='col'>INVENTARIO</th>
  26.     <th width='65' scope='col'>SERIE</th>
  27.     <th width='69' scope='col'>IP</th>
  28.     <th width='90' scope='col'>MARCA</th>
  29.     <th width='66' scope='col'>MODELO</th>
  30.     <th width='65' scope='col'>DISPOSITIVO</th>
  31.     <th width='69' scope='col'>FALLA</th>
  32.     <th width='66' scope='col'>NOMBRE</th>
  33.     <th width='90' scope='col'>ACTIVIDADES</th>
  34.     </tr>
  35.     <tr>
  36.     <td>".$fila['folio']."</td>
  37.     <td>".$fila['fecha']."</td>
  38.     <td>".$fila['hora']."</td>
  39.     <td>".$fila['unidad']."</td>
  40.     <td>".$fila['area']."</td>
  41.     <td>".$fila['reporta']."</td>
  42.     <td>".$fila['tel']."</td>
  43.     <td>".$fila['ext']."</td>
  44.     <td>".$fila['vpn']."</td>
  45.     <td>".$fila['inventario']."</td>
  46.     <td>".$fila['serie']."</td>
  47.     <td>".$fila['ip']."</td>
  48.     <td>".$fila['marca']."</td>
  49.     <td>".$fila['modelo']."</td>
  50.     <td>".$fila['dispositivo']."</td>
  51.     <td>".$fila['falla']."</td>
  52.     <td>".$fila['nombre']."</td>
  53.     <td>".$fila['actividades']."</td>
  54.     </tr>
  55. </table>";
  56.                 }
  57.     else{
  58.         echo "<div class='Estilo2' align='center'>No existe reporte</div>";
  59.     }
  60. }
  61. ?>

Bueno espero su pronta respuesa... muchas gracias!!!
  #2 (permalink)  
Antiguo 19/10/2010, 13:03
Avatar de Ribon  
Fecha de Ingreso: septiembre-2010
Ubicación: El firmamento
Mensajes: 487
Antigüedad: 13 años, 7 meses
Puntos: 91
Respuesta: Ayuda PHP consulta...

no será porque en la consulta

$ARTICULOS=mysql_query("SELECT id_nom, nombre FROM usuarios ");

solo pones el campo id_nom y después pones una coma, te falta elnombre del segundo campo, nombre creoq ue es.

saludos
  #3 (permalink)  
Antiguo 19/10/2010, 13:36
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Respuesta: Ayuda PHP consulta...

Solo son dos campos
"id_nom" y "nombre"

Oh! no entiendo que quieres decirme...
  #4 (permalink)  
Antiguo 19/10/2010, 14:00
Avatar de Ribon  
Fecha de Ingreso: septiembre-2010
Ubicación: El firmamento
Mensajes: 487
Antigüedad: 13 años, 7 meses
Puntos: 91
Respuesta: Ayuda PHP consulta...

A no nada fue error mio, pense que no habias puesto los 2 campos en la consulta pero si lo hiciste xDDD

me fallo la vista nada mas
  #5 (permalink)  
Antiguo 19/10/2010, 14:09
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Respuesta: Ayuda PHP consulta...

Ok... sigo esperando respuestas!!!
  #6 (permalink)  
Antiguo 19/10/2010, 14:22
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
Respuesta: Ayuda PHP consulta...

Probemos :

Código PHP:
Ver original
  1. <?php
  2. $CONEXION = mysql_connect("localhost","root","");
  3. mysql_select_db("bd_control", $CONEXION);
  4.  
  5. $ARTICULOS=mysql_query("SELECT id_nom, nombre FROM usuarios");
  6. if(mysql_num_rows($ARTICULOS) >= '0')
  7. {
  8. echo "<select name=\"ART\">";
  9. echo "<option selected value=\"\"> [ Seleccione ] </option>";
  10. while ($ARTICULO=mysql_fetch_array($ARTICULOS))
  11. {
  12. echo "<option value=\"$ARTICULO[id_nom]\">$ARTICULO[nombre]</option>";
  13. }              
  14. echo "</select>";
  15. }
  16. else{
  17. $ERROR_CONSULTA = "NO SE PUEDEN MOSTRAR LOS PRODUCTOS DEBIDO AL SIGUIENTE ERROR: ";
  18. }
  19. }
  20. ?>

Me cuentas :/
__________________
Gokuh Salvo al mundo. PUNTO!!!!
  #7 (permalink)  
Antiguo 20/10/2010, 08:14
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Respuesta: Ayuda PHP consulta...

Aun asi no me muestra todos los datos del usuario... sigo en lo mismo solo me muestra 1 dato... :(

Etiquetas: Ninguno
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 09:42.