How do you think you can link it to a query on client-side??
You can link it to an AJAX call to the server, which returns the option-list.
The control's filter will do the rest filtering on that option-list.
The best practice would be, to fire an AJAX on page load, to a server function, which will query to the database (MySQL in your case) and fetch the options-list in json format. Assign the option-list to as an input for autocomplete. (Its obviously better than to fire a ajax-request everytime user starts to type-in the search box.)
If you use jquery it can be something like this.
$(function(){ //runs on page load
$.ajax({
type: "POST",
url: "/searchlist/", //server function that returns the search list
data: '',
dataType: "json",
success: function(json){
search_choices = json.list; // search option list
$("input#searchbox").autocomplete(search_choices, {
max: 4,
scroll: false,
autoFill: true,
multiple: true,
matchContains: true,
multipleSeparator: " ",
width: 180
});
}
});
});
I can provide you with example in libraries other than jquery, but i hope this can make you find your way.
Edit: No, your database needn't to have sorted choices. It is your server function, that should be doing all the sorting. Use,
autocomplete( url_to_server_function, options)
and your server function will get search term (keyword user types in search-box), as get request. Filter your database there, and this is the place where you can hook related words along with the results. Just make a list of everything you want to show as suggestion, and return in serialize json format and let autocomplete to take care of matching and sorting the data.