Cbeppe's Profile User Rating: -----

Reputation: 31 Craftsman
Active Posts:
216 (0.11 per day)
16-September 09
Profile Views:
Last Active:
User is offline May 21 2014 01:34 PM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   Cbeppe has not set their status

Posts I've Made

  1. In Topic: Where Can I Get An API For A List Of States And Cities?

    Posted 15 Mar 2013

    If you don't want incredibly long lists to choose from, I'd suggest you get a list of states and a list of counties or cities in the US. Counties if you just need a rough idea where the person is (like for a dating site).

    To implement this, you would have a form with two <select> elements where the first asks the user for his state. The second remains hidden or disabled depending on your UI preference.

    Now in your DB, you would create two different tables. The first one would have a list of states and the second one a list of cities. The example below shows a basic setup. You can write a small script to get from Google's list of cities in the .csv format and into your MySQL DB.

    State Table
    | State ID | State Name | State Initials |
    |     1    |  Alabama   |       AL       |
    |     2    |  Alaska    |       AK       |
    |    ...   |  ...       |       ...      |

    City Table
    |  City ID | State ID |  City Name  |
    |     1    |     1    |  Abbeville  |
    |     2    |     1    |  Adamsville |
    |    ...   |    ...   |  ...        |

    Once the user has selected his state from the first list, you load the relevant cities from your database using an AJAX query and a query from your database looking like this:

    SELECT City Name FROM cities WHERE State ID = $selectedState

    You may have to use a join if you're trying to go directly from a state name to a city, but deal with that if it comes. I'm just showing you the basics of how you could make it work. You don't need an API for this but like Andrewsw said above, this is the better option because it saves you an external request.

    If you need more help, I'm happy to assist when I'm around :)
  2. In Topic: Problem with php 'change password' script / SQL statement

    Posted 13 Mar 2013

    It definitely would. I never put the code past my text editor though. Just moved some stuff around to illustrate what I was saying. Error reporting should always be on when developing.
  3. In Topic: Wildcards with getElementById

    Posted 13 Mar 2013

    I'd look into using JQuery if I were you.

    Alternatively, there's a relatively new Javascript function that allows you to get all elements in a class called document.getElementsByClassName() which is supported by most modern browsers. I haven't used this yet, but it seems interesting enough to look into.

    IDs are more practical to identify a single element, a class works better if you have a group of similar elements.
  4. In Topic: Where Can I Get An API For A List Of States And Cities?

    Posted 13 Mar 2013

    Like Andrew said, you don't really need an API, just a list of states.

    If you want to, you can add a list of cities and associate them with states to create a subsequent list of cities after the user has given you the state. To do this, you'd have to add them to a database (like MySQL) and fetch all the cities associated with the chosen state. This could then be done smoothly with AJAX.

    There might actually exist an API for that last idea, but I don't know of any :)/>
    Good Luck!

    EDIT: It appears that Google has such a list/API
  5. In Topic: Problem with php 'change password' script / SQL statement

    Posted 13 Mar 2013


    I think you found the entire problem with that spelling error :)

    Just goes to show how important a second pair of eyes can be.

My Information

Member Title:
D.I.C Head
Age Unknown
Birthday Unknown
Years Programming:
Programming Languages:

Learning: C++, PHP

Contact Information

Click here to e-mail me



Cbeppe has no profile comments yet. Why not say hello?