mercredi 11 février 2015

SQL prints out row twice?

I have a database table set up storing flight information on a city with the colums Destination_ID, Destinatination_City, Airline, Leaving_From and Arriving.


I run the following query:



foreach( $Airlines as $Airline )
{
$dbQuery = $db->prepare("SELECT * FROM DESTINATIONS
WHERE Airline = '$Airline' AND Destination_City = '$name' ");
$dbQuery->execute();

while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)){
$Arriving = $dbRow ['Arriving'];
$Leaving_From = $dbRow ['Leaving_From'] ; }

echo "$Leaving_From to $Arriving" ;
}


This returns two results with the same values except for the arriving column which is different. However when printing it prints the second row out twice instead of printing both rows.


Im not sure why it does this. Could anyone help?





Aucun commentaire:

Enregistrer un commentaire