PHP Classes

Cities and zip codes: Lookup for cities and zip codes using AJAX

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 63%Total: 5,513 All time: 450 This week: 84Up
Version License Categories
ocities 1.0.0Free for non-comm...Geography, AJAX
Description 

Author

This package can be used to lookup for cities and the respective zip codes.

It uses AJAX to search a file database with cities and the respective zip codes using just the first few letters of the city that the user types in a form text input.

The class can submit an AJAX request to find the cities that match the typed letters and display the city names without reloading the whole page.

It can also search for zip codes if the user types the first numbers of the zip code to search.

The listing that is displayed may be sorted by city name or zip code.

The example uses a file database with French cities but it may be replaced by another file with city and zip code information of anywhere in the world.

ADDITION : I put 2 versions :
'villes_normal/' folder is the old version
'villes/' folder is the new version, with Phonex and Soundex searches and sorting added

Picture of Johan Barbier
Name: Johan Barbier <contact>
Classes: 17 packages by
Country: France France
Age: 52
All time rank: 402 in France France
Week rank: 43 Down4 in France France Down
Innovation award
Innovation award
Nominee: 6x

Details

[PHP5] && [PHP4] This script is used to look for cities and zip codes, via xmlhttp request. It is very simple : If you input letters, the script will look for all the cities and their zip code with a name beginning by these letters, and display them. Same stuff if you input numbers : the script will look for cities whose zip code begins with these numbers. You can sort the list displayed, ordering them by the names, or the zip codes. A joker is available : * Use it to display ALL the cities (beware, it can take a loooong time...there are currently 40000 cities in the data file). Currently, the data file only contains all the French cities. You can change the data file when you call the constructor of the 'ocity' class. Data must be formatted that way : city \tab||several_spaces zip_code\endline city \tab||several_spaces zip_code\endline city \tab||several_spaces zip_code\endline ...and so on

  Files folder image Files (31)  
File Role Description
Files folder imagecss (1 file)
Files folder imagedocs (1 directory)
Files folder imagevilles (2 files, 2 directories)
Files folder imagevilles_normal (1 file, 2 directories)
Accessible without login Plain text file readme.txt Doc. Readme file

  Files folder image Files (31)  /  css  
File Role Description
  Accessible without login Plain text file maindoc.css Data css for documentation

  Files folder image Files (31)  /  docs  
File Role Description
Files folder imageenglish (1 file, 1 directory)

  Files folder image Files (31)  /  docs  /  english  
File Role Description
Files folder imageclasses (1 directory)
  HTML file index.html Doc. Index doc page

  Files folder image Files (31)  /  docs  /  english  /  classes  
File Role Description
Files folder imagecity (1 file, 2 directories)

  Files folder image Files (31)  /  docs  /  english  /  classes  /  city  
File Role Description
Files folder imageoajax (5 files)
Files folder imageocity (7 files)
  HTML file index.html Doc. Index doc page for the package

  Files folder image Files (31)  /  docs  /  english  /  classes  /  city  /  oajax  
File Role Description
  HTML file buildAjax.html Doc. Doc
  HTML file class_oajax.html Doc. Doc
  HTML file search.html Doc. doc
  HTML file setFooter.html Class doc
  HTML file setHeader.html Doc. doc

  Files folder image Files (31)  /  docs  /  english  /  classes  /  city  /  ocity  
File Role Description
  HTML file aVilles.html Doc. doc
  HTML file class_ocity.html Doc. doc
  HTML file getFirst.html Doc. doc
  HTML file getSearch.html Doc. doc
  HTML file sResult.html Doc. doc
  HTML file sSearch.html Doc. doc
  HTML file __construct.html Doc. doc

  Files folder image Files (31)  /  villes  
File Role Description
Files folder imagephp4 (4 files)
Files folder imagephp5 (4 files)
  Accessible without login Plain text file data.dat Data Data file
  Accessible without login Plain text file index.php Example Index example page

  Files folder image Files (31)  /  villes  /  php4  
File Role Description
  Accessible without login Plain text file oajax.cls.php Class PHP4 oajax class
  Accessible without login Plain text file ocity.cls.php Class PHP4 ocity class
  Accessible without login Plain text file phonex.cls.php Class Phonex class
  Accessible without login Plain text file soundex2.cls.php Class Soundex2 class

  Files folder image Files (31)  /  villes  /  php5  
File Role Description
  Accessible without login Plain text file oajax.cls.php Class PHP5 oajax class
  Accessible without login Plain text file ocity.cls.php Class PHP5 ocity class
  Accessible without login Plain text file phonex.cls.php Class Phonex class
  Plain text file soundex2.cls.php Class Soundex2 class

  Files folder image Files (31)  /  villes_normal  
File Role Description
Files folder imagephp4 (2 files)
Files folder imagephp5 (2 files)
  Plain text file index.php Example index page example

  Files folder image Files (31)  /  villes_normal  /  php4  
File Role Description
  Plain text file oajax.cls.php Class Ajax class
  Plain text file ocity.cls.php Class ocity class

  Files folder image Files (31)  /  villes_normal  /  php5  
File Role Description
  Plain text file oajax.cls.php Class Oajax class
  Plain text file ocity.cls.php Class Ocity class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadocities-2006-10-17.zip 124KB
Downloadocities-2006-10-17.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Soundex 2 Download .zip .tar.gz To use the new search features Conditional
 Version Control Unique User Downloads Download Rankings  
 0%
Total:5,513
This week:0
All time:450
This week:84Up
User Ratings User Comments (1)
 All time
Utility:78%StarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:82%StarStarStarStarStar
Examples:82%StarStarStarStarStar
Tests:-
Videos:-
Overall:63%StarStarStarStar
Rank:765
 
Awesome I like very much :)
16 years ago (Nino Paolo Amarillento)
80%StarStarStarStarStar