adding functions and sql queries to support jquery autocomplete in the form