Using phpMyAdmin and running the following query I get 19 registers:
SELECT * FROM trayecto tr, lugar lu WHERE idAeropuerto = '3' AND tr.idLugar = lu.idLugar GROUP BY tr.idAeropuerto, tr.idLugar ORDER BY lu.nombre
but running this query in the website obtaining the data throw and PHP call I only get 18 registers (all of them but the last one entered in the database).
$q=$_GET["q"];
include('init_bd.php');
$selectLugaresDeAeropuerto="SELECT * FROM trayecto tr, lugar lu WHERE idAeropuerto = '".$q."' AND tr.idLugar = lu.idLugar GROUP BY tr.idAeropuerto, tr.idLugar ORDER BY lu.nombre";
$resultLugaresDeAeropuerto = mysql_query($selectLugaresDeAeropuerto) or die('Consulta fallida: ' . mysql_error());
echo "<SELECT SIZE='1' NAME='Lugar'>";
while($row = mysql_fetch_array($resultLugaresDeAeropuerto))
{
printf("<OPTION VALUE=%s>%s</OPTION>", $row["idLugar"], $row["nombre"]);
}
echo " </SELECT>";
mysql_free_result($resultLugaresDeAeropuerto);
include('close_bd.php');
You can execute this PHP to see the result:
http://www.transferbus.com/bd/getLugar.php?q=3
I have a MySQL Database with the following tables and structure:
TRAYECTO
idAeropuerto - int(8)
idLugar - int(8)
idTipoTransporte - int(8)
precio - double
tiempo - varchar(5)
distancia - varchar(5)
LUGAR
idLugar - int(8) - auto_increment
nombre - varchar(40)
Any idea why I get different results with same-like query?
You are connecting to two different databases. Contact your web provider if you need help with connecting to the correct database.