I’m designing a web app, and need a way to pull strings out of a MySQL database and display them as drop down suggestions as the user types data in a form.
For example if the user has entered: “stac” the app should search the DB and provide suggestions like: “stack” “stackoverflow”. I’m looking for something simalar to how a lot of the tag fields here on Stack Overflow work. What is the best way to do this?
Using PHP, this is quite simple.
I would use the
LIKEkeyword in SQL to find the relevant results.Then I would parse the results into JSON, then return it to the client.
A quick example:
JavaScript: (using jQuery)