I am trying to implement the auto-complete script from http://www.devbridge.com/projects/autocomplete/jquery/. It's asking for JSON output like:
{
query:'Li',
suggestions:['Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania']
}
I am using PHP/MySQL. My query to get the suggestions would be something like...
<?
$drug = $_GET['drug'];
$query = mysql_query("SELECT * FROM tags_drugs WHERE drug_name LIKE '$drug%'");
while ($query_row = mysql_fetch_array($query))
{
$drug_name = $query_row['drug_name'];
}
?>
This is where I'm stuck. How do I put the array $drug_name in the suggestions and encode it for json? Thanks in advance!