profile_autocomplete

5 profile.module profile_autocomplete($field, $string)
6 profile.pages.inc profile_autocomplete($field, $string)
7 profile.pages.inc profile_autocomplete($field, $string)

Callback to allow autocomplete of profile text fields.

1 string reference to 'profile_autocomplete'

File

modules/profile/profile.module, line 710
Support for configurable user profiles.

Code

function profile_autocomplete($field, $string) {
  if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) {
    $matches = array();
    $result = db_query_range("SELECT value FROM {profile_values} WHERE fid = %d AND LOWER(value) LIKE LOWER('%s%%') GROUP BY value ORDER BY value ASC", $field, $string, 0, 10);
    while ($data = db_fetch_object($result)) {
      $matches[$data->value] = check_plain($data->value);
    }

    print drupal_to_js($matches);
  }
  exit();
}
Login or register to post comments