php - Autocomplete form with data from json array

I have a booking event script that works perfectly fine. I had to make a change to pass the client_id to get added to the appointment. This is where I'm stuck. I had the first & last names working without an array, but noticed that wasn't a good approach so I added an array.
fetch.php
$clientarray = array();
while($row =mysqli_fetch_assoc($result))
{
$clientarray[] = $row;
}
echo json_encode($clientarray);
The above outputs: [{"id":"57","first_name":"JEFFERSON","last_name":"ANDREAS"}];
index.php
$(document).ready(function(e)
{
$("#title").keyup(function()
{
$("#here").show();
var x = $(this).val();
$.ajax(
{
type:'GET',
url:'fetch.php',
data: 'q='+x, /// start search only when first character is entered. q not empty.
success:function(data)
{
$("#here").html(data); /// display results in <div id=here>
}
,
});
});
});
The script above displays the search results in a where I want to click on a result and autocomplete 3 input boxes: client_id, first_name, last_name.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: failed to create image decoder with message 'unimplemented'
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.