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

  • SEARCH
  • Home
  • 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

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.