Ok to start im writing a script that will tell you the ICAO code for any airport by typing in the airports names there are sometimes more that one airport with the same name so the query returns more than one result.
my problem being i want the ICAO codes that are returned to appear under the rest of the text this is the output at the moment from the script below
EGNT
FANC
IR02
TKPN
You queryed the following Airport: Newcastle
There are 4 Airports with that name their ICAO Codes are:
<?php
$code = $_POST['icaocode'];
$name = $_POST['airportname'];
$host = "localhost";
$user = "homer090_****";
$pass = "******";
$db = "homer090_****";
$tb = "icao";
$conn = mysql_connect($host,$user,$pass) or die("Unable to connect to database")
or die ("couldnt connect");
mysql_select_db("$db", $conn) or die("Unable to select
database $db");
if(empty($code))
{
#############
#NAME LOOKUP#
#############
$query = mysql_query("SELECT * FROM $tb WHERE AirportName LIKE '%$name%'");
while($row = mysql_fetch_array($query)){
$airportcode = $row['ICAO'];
$airportname = $row['AirportName'];
$numofairports = mysql_num_rows($query);
$codes = "$airportcode";
echo "$codes<br>";
}
echo "You queryed the following Airport: <b>$airportname</b>";
echo "<br>";
echo "There are <b>$numofairports</b> Airports with that name their ICAO Codes are:";
#############
#NAME LOOKUP#
#############
}
elseif(empty($name))
{
#############
#ICAO LOOKUP#
#############
$query = mysql_query("SELECT * FROM $tb WHERE icao='$code'");
while($row = mysql_fetch_array($query)){
$data[] = $row;
}
for($i=0;$i<count($data);$i++) {
$airportcode = $data[$i]['ICAO'];
$airportname = $data[$i]['AirportName'];
}
echo "You queryed the following ICAO Code: <b>$airportcode</b>";
echo "<br>";
echo "That ICAO Code refers to: <b>$airportname</b> Airport";
#############
#ICAO LOOKUP#
#############
}
?>
i tried using arays, functions and loops to no success?