By zoliky on
Hi,
This is my function for "search" autocomplete (drupal 6):
function autocomplete_getsearch($string = '') {
$matches = array();
$result = db_query("SELECT * FROM {search_index} WHERE LOWER(word) LIKE LOWER('%s%%')", $string);
while ($row = db_fetch_object($result)) {
$matches[$row->word] = check_plain($row->word);
}
print drupal_to_js($matches);
}
%s%% does not have the same effect on drupal 7. Is there a new way to put the %% signs after %s ? Thanks!
Comments
any idea, please?
any idea, please?
Put the '%' in the string
Put the '%' in the string itself instead of the query. Like so:
See http://api.drupal.org/api/function/user_autocomplete/7 for a complete example ;)