Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/06/2010, 07:40
nightmarex
 
Fecha de Ingreso: junio-2010
Mensajes: 25
Antigüedad: 13 años, 10 meses
Puntos: 1
Ayuda con consultas multitabla.

Hola,

Una vez más, en pos del aprobado, me surgió una nueva duda con mi proyecto. Necesito hacer una consulta multitabla, lo malo es que ya ni me acuerdo de como era.

Lo que trato de hacer es lo siguiente:

Código HTML:
<?php
//include con las funciones
include ("mysql.inc.php");
// Conectamos con el servidor Mysql
conectar($conexion);
// Seleccionamos la base de datos
// con la que queremos trabajar
mysql_select_db("a6715552_garban", $conexion);

//extrae los datos del usuario
$consulta='SELECT datos_usuario.nombre, datos_usuario.app1, datos_usuario.app2, datos_usuario.dni, datos_usuario.movil, registro_sucesos.coord1, registro_sucesos.coord2, registro_sucesos2.coord1, registro_sucesos2.coord2
FROM datos_usuario
INNER JOIN registro_sucesos ON datos_usuario.movil=registro_sucesos.movil
JOIN registro_sucesos2 ON datos_usuario.movil=registro_sucesos2.movil';

//se ejecutan las consultas de las extracciones de datos
$resultado=mysql_query($consulta,$conexion); 

// Este bucle while mostrara todos los datos de los usuarios, uno detras de otro

while ($registro1 = mysql_fetch_array($resultado))
{
	echo "<center><table border='0'>";
	echo "<h1><u><center>";
	echo "<tr><td>","<b><font face='arial'>Nombre:</b></td><td align='right'><font face='arial'>",$registro1['datos_usuario.nombre'],"</td></tr>";
	echo "<tr><td>","<b><font face='arial'>Primer Apellido:</b></td><td align='right'><font face='arial'>",$registro1['datos_usuario.app1'],"</td></tr>";
	echo "<tr><td>","<b><font face='arial'>Segundo Apellido:</b></td><td align='right'><font face='arial'>",$registro1['datos_usuario.app2'],"</td></tr>";
	echo "<tr><td>","<b><font face='arial'>DNI:</b></td><td align='right'><font face='arial'>",$registro1['datos_usuario.dni'],"</td></tr>";
	echo "<tr><td>","<b><font face='arial'>Móvil:</b></td><td align='right'><font face='arial'>",$registro1['datos_usuario.movil'],"</td></tr>";
	echo "<tr><td colspan='2'>","<b><font face='arial'><center>Mapas:</b></td></tr>";
	echo "<tr><td>","<center><b><font face='arial'>Inició la ruta en:<br><img src='$mapainicio'></td>";
	echo "<td>","<center><b><font face='arial'>Último envío de datos:<br><img src='$maparuta'></td></tr>";
	echo "<tr><td><br><img src='$mapainiciot'></td>";
	echo "<td><br><img src='$maparutat'></td></tr>";
	echo "<tr><td colspan='2'>","<center><hr></td></tr>";
	echo "</table>";
} 




//mete en variables las coordenadas del mapa de inicio
while ($datos = mysql_fetch_array($resultado)) 
{ 
	echo $datos['registro_sucesos.coord1']; 
	echo $datos['registro_sucesos.coord2'];
	echo $datos['registro_sucesos2.coord1']; 
	echo $datos['registro_sucesos2.coord2'];
}

//mapas satelite
$mapainicio="http://maps.google.com/staticmap?markers=$while1,$while2&size=312x312&maptype=hybrid&key=ABQIAAAACL7lTKexgA68InhNAOB_GRRtO13F_ulhCFu0-_djha7gKogNnxRWCIfIc4pSFwy2qH99Jsd1CR4TVg&sensor=false";	
$maparuta="http://maps.google.com/staticmap?markers=$while1,$while2,blues|$while3,$while4,midyellow&path=rgb:0x0000ff,weight:5|$while1,$while2|$while3,$while4&size=312x312&maptype=hybrid&key=ABQIAAAACL7lTKexgA68InhNAOB_GRRtO13F_ulhCFu0-_djha7gKogNnxRWCIfIc4pSFwy2qH99Jsd1CR4TVg&sensor=false";
//mapas terrain
$mapainiciot="http://maps.google.com/staticmap?markers=$while1,$while2&size=312x312&maptype=terrain&key=ABQIAAAACL7lTKexgA68InhNAOB_GRRtO13F_ulhCFu0-_djha7gKogNnxRWCIfIc4pSFwy2qH99Jsd1CR4TVg&sensor=false";	
$maparutat="http://maps.google.com/staticmap?markers=$while1,$while2,blues|$while3,$while4,midyellow&path=rgb:0x0000ff,weight:5|$while1,$while2|$while3,$while4&size=312x312&maptype=terrain&key=ABQIAAAACL7lTKexgA68InhNAOB_GRRtO13F_ulhCFu0-_djha7gKogNnxRWCIfIc4pSFwy2qH99Jsd1CR4TVg&sensor=false";






// Desconectamos del servidor          
desconectar($conexion);


?> 
Pero no me devuelve nada. Después, comentando el primer while, el 2º (el while grande) me devuelve el código HTML que lleva dentro, pero no me extrae nada de la base de datos (por ejemplo con ",$registro1['datos_usuario.nombre'],"). Incluso si hay 2 registros en la base de datos, el bucle se repite, pero no me extrae nada.

¿Alguien puede ayudarme?

Saludos :).