<?php include_once("../Controller/Connect.php"); ?>

<?php
function get_video($con , $term){ 
 $query = "SELECT * FROM video_list WHERE title LIKE '%".$term."%' ORDER BY title ASC";
 $result = mysqli_query($con, $query); 
 $data = mysqli_fetch_all($result,MYSQLI_ASSOC);
 return $data; 
}
 
if (isset($_GET['term'])) {
 $getCity = get_video($con, $_GET['term']);
 $cityList = array();
 foreach($getCity as $city){
 $cityList[] = $city['title'];
 }
 echo json_encode($cityList);
}
?>