You are here

function getlocations_fields_province_autocomplete in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/getlocations_fields.functions.inc \getlocations_fields_province_autocomplete()

autocomplete for province

Parameters

string $string:

Return value

Returns province names

1 string reference to 'getlocations_fields_province_autocomplete'
getlocations_fields_menu in modules/getlocations_fields/getlocations_fields.module
Implements hook_menu().

File

modules/getlocations_fields/getlocations_fields.functions.inc, line 470
getlocations_fields.functions.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_province_autocomplete($string = '') {
  $matches = array();
  if ($string) {

    //
    $query = db_select('getlocations_fields', 'f');
    $query
      ->fields('f', array(
      'province',
    ));
    $query
      ->where("LOWER(province) LIKE LOWER(:st)", array(
      ':st' => $string . '%',
    ));
    $query
      ->range(0, 15);
    $result = $query
      ->execute();
    foreach ($result as $row) {
      $matches[$row->province] = check_plain($row->province);
    }
  }
  drupal_json_output($matches);
}