Filter Data from a Database list with PHP from an Input

0

I have an input text with the onkeyup event in which I type a word and it is comparing with a list of the database and returning a button with the same case exists.

I want to continue typing in the course of the options, for example:

I have a list with the words test, tornado, storm and when typing t appears the three options and as you enter it will delete some.

Notes:

I'm using ajax to generate the buttons dynamically, but I'm looking for a solution inside the php for the problem

For now, it only compares if the word is exactly the same as the one I typed in the input to print the button, I want it to print the buttons as I type.

It has to be with button, can not select or options like datalist from html5.

    
asked by anonymous 16.10.2017 / 14:16

1 answer

1

The only way to do this without refreshing the page is with Ajax.

To do this you have to use the sql LIKE operator along with%:

"SELECT coluna FROM tabela WHERE coluna LIKE '$variavel%' " 

Where '$ variable' is the return of your input and '%' says it has more characters later.

This link has more things link

    
16.10.2017 / 14:38