1<?php
2require_once('connection.php');
3
4function get_city($conn , $term){
5 $query = "SELECT * FROM city WHERE city_name LIKE '%".$term."%' ORDER BY city_name ASC";
6 $result = mysqli_query($conn, $query);
7 $data = mysqli_fetch_all($result,MYSQLI_ASSOC);
8 return $data;
9}
10
11if (isset($_GET['term'])) {
12 $getCity = get_city($conn, $_GET['term']);
13 $cityList = array();
14 foreach($getCity as $city){
15 $cityList[] = $city['city_name'];
16 }
17 echo json_encode($cityList);
18}
19?>
20
1 <?php
2 require "database/database.php";
3 $data = mysql_query("SELECT * FROM countries");
4 $result = array();
5 while($row = mysql_fetch_assoc($data)) {
6 $result[] = array(
7 'label' = $row['countryname'],
8 'value' = $row['countryname']
9 );
10}
11echo json_encode($result);
12flush();
13}
14?>
15