function getlocations_fields_city_autocomplete in Get Locations 7
Same name and namespace in other branches
- 7.2 modules/getlocations_fields/getlocations_fields.functions.inc \getlocations_fields_city_autocomplete()
autocomplete for city
Parameters
string $string:
Return value
Returns city names
1 string reference to 'getlocations_fields_city_autocomplete'
- getlocations_fields_menu in modules/
getlocations_fields/ getlocations_fields.module - Implements hook_menu().
File
- modules/
getlocations_fields/ getlocations_fields.functions.inc, line 495 - getlocations_fields.functions.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_fields_city_autocomplete($string = '') {
$matches = array();
if ($string) {
//
$query = db_select('getlocations_fields', 'f');
$query
->fields('f', array(
'city',
));
$query
->where("LOWER(city) LIKE LOWER(:st)", array(
':st' => $string . '%',
));
$query
->range(0, 15);
$result = $query
->execute();
foreach ($result as $row) {
$matches[$row->city] = check_plain($row->city);
}
}
drupal_json_output($matches);
}