SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Countries to continents?

    I have a friend with pretty big db with users from all over the world.
    The table have a lot of info about the users, like name, address, e-mail, country, and so on.
    Now he wants to add one field to the db, listing what continent they live in.
    So, all the people in France will have Europe added.

    I'm not sure how I can do this the easiest way. Should I run a query for every country and change.
    Or is it easier to make some kind of temporary web page where they are listed and I can click on the correct continent.
    That would be pretty good, not sure how though, but if I had a list of the users sorted by country.

    Like a table

    NAME | COUNTRY | CONTINENT MENU LIST
    Peter USA North America, South America, Europe, Asia,...
    Michel France North America, South America, Europe, Asia,...

    Then, when picking North America on the first one, all the others that have USA as country will be updated with the same continent.
    Is that something that can be done or is there an easier way of doing it?

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,068
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    For each time a country is listed in the database, are all the occurrences spelt the same?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Countries by continent - will help you get a list, though if you are into sparql and dbpedia you can extract them as data.

    I'd make a list of how many unique countries you have first, and really assure yourself that this is worth doing.

    You could just make a table containing those countries, and match the continents to them.

    You can then either JOIN the tables when "sort by continent is required", or run an update which fills in the holes in the main database from the continents database.

    "UPDATE mytable set continent = "Europe" where country = "France";

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    For each time a country is listed in the database, are all the occurrences spelt the same?
    Ah, good one -- dirty data.

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes, all countries are selcted from a list, so they are spelled the same way. ;-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •