Foros del Web » Programando para Internet » PHP »

Problema en un While

Estas en el tema de Problema en un While en el foro de PHP en Foros del Web. Código PHP: <? $get_integrantes = mysql_query ( "SELECT * FROM integrantes_bandas AS ib LEFT JOIN instrumentos AS i ON i.id_instrumento=ib.instrumento_integrante WHERE ib.banda_integrante='" . $idbanda . "' ORDER BY ib.instrumento_integrante" ); while ( $row  =  mysql_fetch_array ( $get_integrantes )) {     echo  "<b>" . $row ...
  #1 (permalink)  
Antiguo 28/02/2007, 19:27
 
Fecha de Ingreso: diciembre-2005
Mensajes: 249
Antigüedad: 18 años, 4 meses
Puntos: 0
Problema en un While

Código PHP:
<?
$get_integrantes
=mysql_query("SELECT * FROM integrantes_bandas AS ib LEFT JOIN instrumentos AS i ON i.id_instrumento=ib.instrumento_integrante WHERE ib.banda_integrante='".$idbanda."' ORDER BY ib.instrumento_integrante");

while (
$row mysql_fetch_array($get_integrantes))
{
    echo 
"<b>".$row['nombre_integrante']."</b><br>".$row['nombre_instrumento']."";
    if (
$row['instrumento_integrante2'] != ''
    {
       
$get_integrantes2=mysql_fetch_array(mysql_query("SELECT * FROM integrantes_bandas AS ib LEFT JOIN instrumentos AS i ON i.id_instrumento=ib.instrumento_integrante2 WHERE ib.banda_integrante='".$idbanda."' ORDER BY ib.instrumento_integrante"));
       echo 
" / ".$get_integrantes2['nombre_instrumento']."";
    }
       echo 
"<br><br>";
}
?>
Con el primer integrante q aparece, aparece perfectamente ,pero el instrumento2 del segundo integrante aparece el mismo instrumento2 q el primer integrante y asi sucesivamente :S:S

Tienen idea?

Saludasos
  #2 (permalink)  
Antiguo 28/02/2007, 20:05
 
Fecha de Ingreso: diciembre-2005
Mensajes: 249
Antigüedad: 18 años, 4 meses
Puntos: 0
Re: Problema en un While

Nadie sabeE?
  #3 (permalink)  
Antiguo 28/02/2007, 20:40
Avatar de gerson  
Fecha de Ingreso: febrero-2005
Ubicación: Lima
Mensajes: 481
Antigüedad: 19 años, 2 meses
Puntos: 4
Re: Problema en un While

Pues tu segundo SELECT siempre te va a devolver el mismo dato puesto q no hay ninguna igualdad con algun dato cambiante.

"SELECT * FROM integrantes_bandas AS ib LEFT JOIN instrumentos AS i ON i.id_instrumento=ib.instrumento_integrante2 WHERE ib.banda_integrante='".$idbanda."' ORDER BY ib.instrumento_integrante"

tu unica condicion en le WHERE ib.banda_integrante='".$idbanda."' siempre es la misma por lo menos de haber otra condicion mas, una comparacion con algun dato q devolvio el primer SELECT...

espero haberme explicado bien.

Salud2
__________________

  #4 (permalink)  
Antiguo 28/02/2007, 21:14
 
Fecha de Ingreso: diciembre-2005
Mensajes: 249
Antigüedad: 18 años, 4 meses
Puntos: 0
Re: Problema en un While

Gracias amigo!
puse que la consulta sea :

Código PHP:
$get_integrantes2=mysql_fetch_array(mysql_query("SELECT * FROM integrantes_bandas AS ib LEFT JOIN instrumentos AS i ON i.id_instrumento=ib.instrumento_integrante2 WHERE ib.id_integrante='".$row['id_integrante']."' ORDER BY ib.instrumento_integrante")); 
y me funciono de lujo
un abrazo!
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 15:55.