Answers for "jquery autocomplete database"

0

jquery autocomplete database

<?php
require_once('connection.php');
 
function get_city($conn , $term){ 
 $query = "SELECT * FROM city WHERE city_name LIKE '%".$term."%' ORDER BY city_name ASC";
 $result = mysqli_query($conn, $query); 
 $data = mysqli_fetch_all($result,MYSQLI_ASSOC);
 return $data; 
}
 
if (isset($_GET['term'])) {
 $getCity = get_city($conn, $_GET['term']);
 $cityList = array();
 foreach($getCity as $city){
 $cityList[] = $city['city_name'];
 }
 echo json_encode($cityList);
}
?>
Posted by: Guest on November-06-2020
0

jquery autocomplete database

<?php
   require "database/database.php";       
   $data = mysql_query("SELECT * FROM countries");
   $result = array();
   while($row = mysql_fetch_assoc($data)) {
    $result[] = array(
    'label' = $row['countryname'],
    'value' = $row['countryname']
    );
}
echo json_encode($result);
flush();
}
?>
Posted by: Guest on November-06-2020

Code answers related to "jquery autocomplete database"

Code answers related to "Javascript"

Browse Popular Code Answers by Language