I'm trying to get a SQL query to run through an array showing a list of airline names. However the first result is always empty
1.
Cathay Pacific
British Airways
Singapore Airlines
etc, when it should show:
Cathay Pacific
British Airways
Singapore Airlines
The code I've got is:
foreach ($flights as $b) {
$flightdata = explode(" ", $b);
$airline = $flightdata[2];
$link = mysql_connect('xxx', 'xxx', 'xxx');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxx") or die(mysql_error());
$fetchairlinecode = "SELECT * FROM `airlines` WHERE `iatacode` = '$airline' LIMIT 0 , 30";
$rs=mysql_query($fetchairlinecode);
while ($row = mysql_fetch_array($rs)){
echo $row['airlinename'];
}
mysql_close($link);
}
Can anyone see what I'm doing wrong?