Hi does anyone have any ideas why my JQuery autocomplete is not bringing back any results?
Here is the PHP code:
$result = mysql_query("SELECT * FROM stations where StationName like '%" . mysql_real_escape_string($_GET['term']) . "%'");
$array = array();
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$row_array[] = $row['StationName'];
array_push($array, $row_array);
}
echo json_encode($array);
Here is the JS code:
$(function() {
$('#location').val("");
$("#location").autocomplete({
source: "autocomplete.php",
minLength: 2,
select: function(event, ui) {
$("#location").val(ui.item.location);
}
});
});
And finally the HTML:
<input type='text' class="suggest" id='location'>