Search code examples
javascriptphpmysqlhtmlhtml-datalist

How to use HTML5 Datalist with MySQL


HTML5 introduces new tag datalist, which connected to <input list="datalistID"> provides autocomplete functionality.

Question is - what is the best way to connect this datalist suggestion to MySQL table with high amount of rows (let's say 50K).


Solution

  • The best way to connect it is via the data attribute or the <datalist> tag which takes any URI or IRI to get the data as XML.

    You can then change the URI/IRI based on the input value. And also you should limit your resultset to a useful maximum number of lines, you don't want to transfer megabytes just for auto-complete.