views:

31

answers:

1

I want to make a few customizations to jQuery UI Autcomplete:

1) If there are no results found it should output "no results found" in the list.

2) Is it possible to highlight/bold the letters in the results as they are being typed? For example if I type "ball" and I have "football" in my results it needs to output as foot ball

3) Is it possible for the results that appear at the top to match the beginning of the string. For example suppose I have 3 entries in my database:

  • Astrologer
  • Space Station
  • Star

I start typing "st" - this will bring up those 3 entries in that order. But I want "Star" to be the first result.

The MySQL query being used at the moment to generate the results is:

$query = mysql_query("SELECT id, name FROM customer WHERE name LIKE '%".$_GET['term']."%' ORDER BY name");
A: 
  1. You can simply echo 'No results found' inside the script that returns the list if num rows from your mysql_query is 0.

  2. This was possible in the original Autocomplete plugin but I can't see it anywhere in the JQuery UI documentation.

  3. You may have to run two separate mysql queries - the first one looking for LIKE '".$_GET['term']."%' and the second one as you have it, but excluding the results you've already got from the first query.

bcmcfc