I have
<form action='' method='post'>
City name <br /><br />
<input type='text' name='search' value='' class='auto'>
</form>
and
<script type="text/javascript">
$(function() {
//autocomplete
$(".auto").autocomplete({
source: "search.php",
minLength: 1
});
});
</script>
This is autocomplete. And now I receive fields from MySQL base in search.php file:
if(isset($_GET['term']))
{
$city = array();
$airport = array();
$citysearchsql = mysqli_query(db(),"SELECT * FROM citycode WHERE cityname LIKE '%".$_GET['term']."%' ");
while($citysearchresult = mysqli_fetch_array($citysearchsql))
{
$airnamesql = mysqli_query(db(),"SELECT * FROM airports WHERE citycode='".$citysearchresult['citycode']."' ");
while($airnameresult = mysqli_fetch_array($airnamesql))
{
$airport[] = $airnameresult['airportname'];
}
$city[] = $citysearchresult['cityname'];
}
echo json_encode($city);
}
Base has two tables citycode and airports. When user writes city name, need to show city name and under city name show airport name, like here
I cant do it with json_encode.
any ideas, anybody can help me