Adding Provinces and States by country

Discussion in 'Modules / Plugins / Modifications' started by cflo, Jan 9, 2009.

  1. cflo Customer

    I appreciate your time and help. Thanks!
    Crossing my fingers on this one.

  2. Lhotch curmudgeon

    After setting my script houds on the hunt it appears there are 2 functions for collecting the state data. The one above that Mike mentioned and one in /includes/functions.php and the user registration actually uses that one instead of the other one.

    To be safe I would change both of them so the query is....

    SELECT abbrev, name FROM class_states ORDER BY abbrev asc;
  3. cflo Customer

    Hi thanks, you mean the code to read:

    $sSQL="SELECT abbrev, name FROM class_states ORDER BY abbrev ASC";

    If so, it did not work.
    Thank you.

  4. Lhotch curmudgeon

    Yes, thats what I mean, you still need to add USA and CAN in front of the abbreviations though.
  5. cflo Customer

    This is what Blair has sent me, but I have no idea how to properly code it so any help would be much appreciated.

    "Unfortunately, the system doesn't associate states with countries. So, you'll have to modify the states table by adding another column. Then, you'll have to modify the sql statement by returning the results by country ID first, then name."

  6. Mike-N-Tosh Developer & Moderator

    In the examples given this is how it would work.

    In the abbrev column for each state, put the country (e.g. USA, CAN).

    Then the sort should be for ORDER BY abbrev ASC, name ASC. As the abbrev column is sorted first, that then puts in this example ALL the CAN states/provinces first alphabetically. It would then list all the USA states alphabetically.

    The code given for the sql search would need to be changed in both the Users.php AND the functions.php.
    PHP:
    $sSQL="SELECT name, abbrev FROM ".PREFIX."states ORDER BY abbrev ASC, name ASC";
    The Users.php (/includes/classes/kernal) around line 318 in the function getStates().

    The functions.php (/includes/) around line 102 in the function getStates.

    -Mike
  7. cflo Customer

    Now it works, thank you!


  8. Mike-N-Tosh Developer & Moderator

    Glad to hear it! Your welcome. Thanks to lhotch too!!!

    -Mike
  9. cflo Customer

    Thanks a bunch guys for your help on this!
  10. cflo Customer

    Hi its me again, I upgraded to the new v4.1.3 Developer, and now Im back to square 1.
    Unfortunately I did not find this code under the two files you specified.

    Please advise where I should be looking for v4.1.3.
    Thank you.

Share This Page