Well, I've only done something like this once on my wish list web site (www.yourlistonline.com
). I have a 3 cycle algorithm which works like this...
The visitor enters a first name and a last name.
first I create a "matches" array
Next I query the database for exact match.
Next I query for exact match on last name,
then I query for exact match on first name,
then I query for "LIKE%" matches on both first and last name.
With each query, I add an entry to my matches array. If the name already exists, I increment a counter for that name. Then I just sort the array based on the highest number of hits (or counts). Seems to work well for me.