function profile_autocomplete in Drupal 6
Same name and namespace in other branches
- 5 modules/profile/profile.module \profile_autocomplete()
 - 7 modules/profile/profile.pages.inc \profile_autocomplete()
 
Callback to allow autocomplete of profile text fields.
1 string reference to 'profile_autocomplete'
- profile_menu in modules/
profile/ profile.module  - Implementation of hook_menu().
 
File
- modules/
profile/ profile.pages.inc, line 109  - User page callbacks for the profile module.
 
Code
function profile_autocomplete($field, $string) {
  $matches = array();
  if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) {
    $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);
    }
  }
  drupal_json($matches);
}