You are here

function biblio_autocomplete in Bibliography Module 5

Same name and namespace in other branches
  1. 6.2 biblio.module \biblio_autocomplete()
  2. 6 biblio.module \biblio_autocomplete()
  3. 7 biblio.module \biblio_autocomplete()
  4. 7.2 biblio.module \biblio_autocomplete()

biblio.module for Drupal

Copyright (C) 2006 Ron Jerome

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

1 string reference to 'biblio_autocomplete'
biblio_menu in ./biblio.module
Implementation of hook_menu().

File

./biblio.module, line 22

Code

function biblio_autocomplete($field, $string = '') {
  $matches = array();
  $result = db_query_range("SELECT {$field} FROM {biblio} WHERE LOWER({$field}) LIKE LOWER('%s%%') ORDER BY {$field} ASC", $string, 0, 10);
  while ($data = db_fetch_object($result)) {
    $matches[$data->{$field}] = check_plain($data->{$field});
  }
  print drupal_to_js($matches);
  exit;
}