if { [string length $search] == 0 } {
ns_write "No results"
ad_script_abort
} elseif { [string length $search] < 3 } {
# Show all results if search string is 1 or two characters.
set search ""
}
set search [string tolower $search]
set package_id [ad_conn subsite_id]
set response ""
# Get users in the current subsite only
db_foreach get_search_results "
select n,n,n
from my_table
order by n
# select distinct u.username,
# p.first_names || ' ' || p.last_name as name,
# u.username as email
# from pers p, use u, acs_rels rel, app_groups ag
# where p.person_id = u.user_id
# and u.user_id = rel.object_id_two
# and rel.object_id_one = ag.group_id
# and ag.package_id = :package_id
# and (lower(p.first_names || ' ' || p.last_name) like '%$search%'
# or lower(u.username) like '%$search%')
# order by name
" {
set one_result "$name ($email)"
# Bold search text as you type
set start [string first $search [string tolower $one_result]]
set end [expr $start + [string length $search]]
set one_result_bolded "[string range $one_result 0 [expr $start-1]][string range $one_result [expr $start] $end][string range $one_result [expr $end+1] [expr [string length $one_result] - 1]]"