<?php

include './conn.php';





$term = utf8_decode($_GET['name']);

$pattern = '/' . $term . '/i';



$sql = "SELECT name FROM flight_city where name like '" . $term . "%' GROUP BY name order by name";

$query = mysql_query($sql);





$rows = array();



while ($r = mysql_fetch_assoc($query)) {



    foreach ($r as $value) {



	if (preg_match($pattern, $value)) {



	    $rows[] = utf8_encode($value);
	}
    }
}



$json = json_encode($rows);

echo $json;
?>