<?php

include './conn.php';

$bla = $_GET["name"];

$bla = str_replace(' ', '', $bla);

$query = mysql_query("SELECT REPLACE(number, ' ', '') AS number FROM flight_numbers where REPLACE(number, ' ', '') like '" . $bla . "%' GROUP BY number order by number ");

if ($query === FALSE) {

    die(mysql_error()); // TODO: better error handling
}

$json = array();



while ($student = mysql_fetch_array($query)) {

    $json[] = array(
	'value' => $student["number"],
	'label' => $student["number"]
    );
}



echo json_encode($json);
?>