How to handle different address formats

Discussion in 'PHP' started by stephan2307, Mar 25, 2013.

  1. #1
    I am working on a web based system. One part will be to store details such as addresses, phone numbers etc.

    The problem I am having is that different countries have different address formats.

    Does anyone have any idea how I can handle various country address formats? Do I need to create a different table for each country??
     
    stephan2307, Mar 25, 2013 IP
  2. trecords

    trecords Well-Known Member

    Messages:
    145
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #2
    I am not sure but I think adresses are same, there are difference on some countries don`t have State or Postal code formats are differs. Give some example plz.
     
    trecords, Mar 26, 2013 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    You'll need fields for building number, street, city, postal code and country. Some countries also have one or two things between city and country, so you can have 2 additional fields called something like sub_1 and sub_2. That should cover all addresses in the world.

    How you format them if you print them for postal delivery is the problem - there are dozens of formats. It doesn't matter what order the fields sit in the database, but it does matter where they're put on the envelope or mailing label.

    BTW, none of your fields should be numeric - they're all character fields. (Even the building "number" can be alpha or alphanumeric.)
     
    Rukbat, Mar 26, 2013 IP
  4. Vick.Kumar

    Vick.Kumar Active Member

    Messages:
    138
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #4
    For example,
    123 Apple Road,
    (Suburb, State, Postcode),
    (Country)

    ^ That's how almost every address is presented.

    So you can have 'Street' (incs unit/house number, street name(incs road/street/place)), 'Suburb', 'State', 'Postcode', 'Country'.
     
    Vick.Kumar, Mar 27, 2013 IP