CodeIgniter Forums

Full Version: How does facebook (and myspace) do this....?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]flyenig[/eluser]
When you register on facebook or myspace, or u go to settings and u want to select your school,
They use a jquery autocomplete that has a list of every school.

Or when you want to select a city, and you start typing your city, the autocomplete shows up with the cities.

Are they storing all the cities, schools, countries, etc in a Database or are they getting it from some kind of API or something?

becasue im trying to implement something like this in my project.


Thanks Smile

El Forum

[eluser]richthegeek[/eluser]
The cities and so on are stored in a database, but the database is populated by past users. That is, when you can't find your school, you just type it in and it "creates" it.

Then when the next person from your school types in the name, your result shows up.

The way this isn't abused is because each user has a limited number of slots in which to provide spam, or expletives, or similar, and so when there are 100+ users for a valid result, they quickly outweigh the bad results.

For actually matching what you typed in, check out MySQL's LIKE and PHP's levenshtein function.

El Forum

[eluser]flyenig[/eluser]
yea thats what i was thinking, thanks for the info