(This question is following on from my previous problem which has been fixed (Here)
I found a similar question to this (Here) but the solution wasn't quite what I was looking for.
I currently have a JQuery styled autocomplete search engine on my site, called (fcbkcomplete). The original operation of the script ran from a .txt file, looked up the manually-entered values and outputted them in the autocomplete results. However, I want the script to get the values from a MYSQL database instead of being manually entered into a .txt file as I eventually want the user to have the option of adding their own values.
I have therefore made the Javascript call a .php file instead of .txt with this script in it:
//connection details
$getData = mysql_query("SELECT Name FROM tblIngredient");
while($info = mysql_fetch_array($getData))
{
echo "{\"key: value:\";
echo $info['Name'];
echo "key: value:\"";
echo $info['Name'];
echo "}, ";
}
This script works and outputs the data in the correct format:
{"key": "vodka","value": "vodka"}, {"key": "tequila","value": "tequila"},
So I need to know how I then convert this JSON output into data.txt (so as the database table grows, the .txt file is updated automatically when the script is run)
This is the final step in the search on my site so any help is much appreciated.
-Matt