autocomplete - doesn't search in full string
hello. im using this php to generate source for my autocomplete:
- $return_arr = array();
- $get_item = mysql_query("SELECT * FROM my_table WHERE name LIKE '%" . $_GET['term'] . "%' ORDER BY id");
- while($item = mysql_fetch_assoc($get_item)) {
- $row_array['id'] = $item['id'];
- $row_array['label'] = $item['name'].' - '.$item['city'];
- $row_array['value'] = $item['name'].' - '.$item['city'];
- $row_array['city'] = $item['city'];
- array_push($return_arr,$row_array);
- }
- echo json_encode($return_arr);
- $('#inputfield').autocomplete({
- source: "ajax_data.php",
- minLength: 2
- });
now i have for example same five values in db in column 'name' (value: "myname") and 5 different values in column 'city' ("prague", "ny", "madrid", "london", "washington")
so when i enter "myname" into my input field autocomplete offers:
- myname - prague
- myname - ny
- myname - madrid
- myname - london
- myname - washington
but when i add the dash so the input text is "myname - ", input doesn't offer anything (doesn't work even with just one space: "myname ")
where's the problem?
thanks