Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 917741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:15:28+00:00 2026-05-15T18:15:28+00:00

i need to develop a php script who ask for a city name and

  • 0

i need to develop a php script who ask for a city name and return a simple echo with the geographical coordinates of the city.

Input data: Cityname OR Cityname, Country

I know there is a free database called GeoNames were you can download a database who contains this information, but i really dont know how to export this database to my MySQL server, there 3 files who can be the think i need but i dont know what i need to pick:

cities1000.zip                             11-Jul-2010 01:13  3.4M  
cities15000.zip                            11-Jul-2010 01:13  1.1M  
cities5000.zip                             11-Jul-2010 01:13  1.8M  

see were this files are

So, its a good idea to use this data base?, there is an online API to do this?, how can i import the data from citiesXXXX to MySQL?, any suggestion for the php script?… Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:15:29+00:00Added an answer on May 15, 2026 at 6:15 pm

    I use Google Maps to get any information about a location: http://code.google.com/apis/maps/index.html

    It can return the data in XML or JSON so you can easily parse and save the data.

    Here is an example link for Washington DC: http://maps.google.com/maps/geo?output=xml&oe=utf8&sensor=false&hl=en&q=washington%20dc

    It will return this XML data:

        <?xml version="1.0" encoding="UTF-8" ?>
    <kml xmlns="http://earth.google.com/kml/2.0">
        <Response>
            <name>washington dc</name>
            <Status>
                <code>200</code>
                <request>geocode</request>
            </Status>
            <Placemark id="p1">
                <address>Washington, DC, USA</address>
                <AddressDetails Accuracy="4" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
                    <Country>
                        <CountryNameCode>US</CountryNameCode>
                        <CountryName>USA</CountryName>
                        <AdministrativeArea>
                            <AdministrativeAreaName>DC</AdministrativeAreaName>
                            <SubAdministrativeArea>
                                <SubAdministrativeAreaName>District of Columbia</SubAdministrativeAreaName>
                                <Locality>
                                    <LocalityName>Washington</LocalityName>
                                </Locality>
                            </SubAdministrativeArea>
                        </AdministrativeArea>
                    </Country>
                </AddressDetails>
                <ExtendedData>
                    <LatLonBox north="38.9645516" south="38.8256040" east="-76.9083064" west="-77.1644252" />
                </ExtendedData>
                <Point>
                    <coordinates>-77.0363658,38.8951118,0</coordinates>
                </Point>
            </Placemark>
        </Response>
    </kml>
    

    You can then use a function like SimpleXML or DOMDocument to parse the data. If you just want to echo the coordinates as supported in the tag simple use this code:

    $xml = simplexml_load_string(file_get_contents('http://maps.google.com/maps/geo?output=json&oe=utf8&sensor=false&hl=de&q='.urlencode($address)));
    echo (string)$xml->Placemark->Point->coordinates;
    

    If you want the single coordinates use the data in the tag e.g.:

    $coordinates = explode(',', $xml->Placemark->Point->coordinates);
    echo $coordinates[0];
    echo $coordinates[1];
    

    I hope that is what you are searching for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer private string ChangeXmlContent(Uri url, XmlDocument xdoc, string description) { XmlNode… May 16, 2026 at 11:12 am
  • Editorial Team
    Editorial Team added an answer These guys seem to cover all the options. Win32: full-screen… May 16, 2026 at 11:12 am
  • Editorial Team
    Editorial Team added an answer Diego, over in the nhibernate mailing list, helped me see… May 16, 2026 at 11:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have cron job - php script which is called one time in 5
I am trying to develop a web application for which I need to capture
I need to develop a server side application that opens sockets and manages communication
CodeIgniter is brilliant but I'm using it to develop a site where users need
I need to develop a software which works for both windows and Mac OS.
I need to develop an application with following features and want to understand if
I have several independent executable Perl, PHP CLI scripts and C++ programs for which
I am looking for a form class that: Is standalone/doesnt need a framework to
I need your advice. We have an already working web resource management application, we
I have used PHP a lot , and now i want to give back

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.