I am trying to get the Devbridge Autocomplete jQuery script to work, and I am oh so very close. I can get it to give me suggestions (dropdown values) however I need to use it's data attribute.
The suggested JSON formatting as as follows:
{
suggestions: [
{ value: "United Arab Emirates", data: "AE" },
{ value: "United Kingdom", data: "UK" },
{ value: "United States", data: "US" }
]
}
So far, I have managed this:
{
"suggestions": [
"Show Name 1",
"Show Name 2"
],
"data": [
"1",
"2"
]
}
The code producing that output is as follows:
$reply = array();
$reply['suggestions'] = array();
$reply['data'] = array();
while ($row = $result->fetch_array(MYSQLI_ASSOC))//loop through the retrieved values
{
//Add this row to the reply
$reply['suggestions'][]=$row['SHOW_NAME'];
$reply['data'][]=$row['SHOW_ID'];
}
//format the array into json data
echo json_encode($reply);
Any suggestions? I can't figure out how to combine the two data elements into one array, let alone prepend them with 'value' or 'data'...