CodeIgniter Forums
How does facebook (and myspace) do this....? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: How does facebook (and myspace) do this....? (/thread-29812.html)



How does facebook (and myspace) do this....? - El Forum - 04-21-2010

[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


How does facebook (and myspace) do this....? - El Forum - 04-21-2010

[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.


How does facebook (and myspace) do this....? - El Forum - 04-21-2010

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