I am using php and javascript to create a dynamicly populated autocomplete search engine for my wordpress site.
Example: user wants to search for “Nike Shoes” so they type in Nike Shoes into the search engine and they should see Nike Shoes as a suggestion after they type the first 3 letters.
I am having an issue where only the word Nike shows up as a suggestion. This happens with any terms you type into the search engine. Only the first word of the string will show up. I am sure it’s to do with the spaces in between words but not so sure on how to fix it.
Here is my code that is populating the autocomplete dynamically:
var availableTags = '<?php $result = mysql_query("select * from state");
$row = mysql_fetch_array($result);
echo $row['name']; ?>'.split(" ");
$( "#title" ).autocomplete({
source: availableTags,
minLength: 3,
position: { my : "left top", at: "left top" },
appendTo: "#search-container"
});
});
I created this code from this site: http://www.tizag.com/mysqlTutorial/mysqlquery.php
If someone could please help me I would be very greatful.
Thanks,
Steve
I am using this function for auto suggest list. you can use it with slight modification
Usage: