Now a days most of the web sites want to use their data and want to suggest end user suggestion based on that data while they are typing in the text field. Problem we face when we use like clause of the MySQL query and try to fetch the relevant words but like clause will only fetch the exact matching words not the relevant or close words. To address this issue, I have tried to use soundex of MySQL for creating the auto suggest for typing. Here is the stored procedure which can check for the relevant word in the table and then suggest the correct word.
Here is the country table and data which I have used in this example.
I have created small html file (index.html) and php file (request.php) for calling the required MySQL function call.
Now create the index.html file and paste the following code in it for checking the auto suggest MySQL function call.
You can copy paste the code into the respective files and put then under Apache server /var/www/html folder. Now you can test the auto suggest for the countries if you type the wrong name for the country it will suggest the correct name for it.
Now you can use this example and implement it on your table data.
Comments