jquery autocomplete database

Solutions on MaxInterview for jquery autocomplete database by the best coders in the world

showing results for - "jquery autocomplete database"
Lola
26 Feb 2016
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
Maryam
09 Oct 2020
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