Generate autocomplete values from database

Generate autocomplete values from database

Hello. I'm new to jquery. Im trying to use the autocomplete part of the ui but I want the values to be generated from a database through php and not just have the values posted. This is what I tried to generate the values in the search.php

  1. $q = strtolower($_GET["term"]);
    if (!$q) return;
       
        $sql = "SELECT member_id, first_name, last_name
            FROM member";
               
        $record = find_by_sql($sql); // I have a function that would run the query
            $items = array();
       
        foreach($record as $attribute=>$value){
              $items[$attribute] = $value;
        }