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