I've seen some (well-explained) examples where the available results of a live search are found in an xml file. But only a few (badly-explained) ones where the results come from a database. I'm interested in the second case.
One solution could be to prefetch the database data and put them in an xml object and the rest could work the same way. And this is something I can easily implement.
What I'm looking for is for another way, where the user types a letter (e.g. 'c') and the suggestions are generated on the spot (e.g. 'carrot', 'cabbage', 'celery', 'citrus'). Would this be achieved with a call to the database like
"SELECT name FROM vegetables WHERE name LIKE c%"
?
And what if the user then presses another letter? (e.g. 'ca', so the recommended results should be 'carrot', 'cabbage'). Every key pressed should initiate a new SELECT
? For some reason it doesn't sound like a good solution.
Is there a way to achieve this second method?