Results 1 to 5 of 5

Thread: Country State City Lists

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question Country State City Lists

    Hello,

    I have a situation regarding ajax script. Please check the attachments. It is not possible to generate the city list by selection of the state from the database.

    Please help.

    Thanks & Regards.
    Attached Files Attached Files

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Country State City Lists

    aside from having a bad design for your database, it doesn't include any cities. how do you expect to get a list of cities if you don't HAVE a list of cities?

    depending on what you're doing -- in theory a city list is convenient and ensures that your customers enter in the correct city name. in practice, not so much. storing a database of every city, town and village in the entire world is insane to say the least. if you were simply listing out locations that you had products in, or something, then you would have a limited list that would be somewhat easy to keep track of. the entire world's list of cities is not so. most people just have a text field that lets a user enter in their city and be done with it.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question Re: Country State City Lists

    Hello kows,

    Thanks a lot for reply and find my mistake. I have attached the project once more. Please check and try to help me out.

    Thanks a lot in advance.
    Attached Files Attached Files

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Country State City Lists

    well, this time your project doesn't include the other table, but I ended up taking it from the original zip file. you're using phpMyAdmin; you know you can export more than one table at once, right?

    anyhow, let's get to it.

    first problem: your XML for the cities in xml_provided_data2.php is invalid. you are opening the tag <city> and closing it with </state>. you need to close it with </city>.

    second problem: xml_provided_data2.php is being given an ID in the GET filter variable (an incorrect ID, at that); you need to give it a string to return the desired result. to fix this, you need to find this line in xml_provided_data.php:

    PHP Code:
    $xml $xml '<state id="' $iscountry '">' $row['state'] . '</state>'
    and replace it with:

    PHP Code:
    $xml $xml '<state id="' $row['state'] . '">' $row['state'] . '</state>'
    fixing both of the things I've outlined should fix your problem.

    now, I can tell by simply glancing at your PHP and the JavaScript file that this is badly hacked together. I would suggest taking some tutorials on how PHP and Ajax work and then attempting to rewrite this entire script. for example, you have a bunch of functions in your JavaScript file that are almost identical to other JavaScript functions with very small changes; these could be merged into one function. you're also connecting to your MySQL database like, four times in your script [you include dbcon.php [1], then actually call mysql_pconnect() [2] within your index file, and then later on you copied and pasted the code that includes dbcon.php [3] and then calls mysql_pconnect() [4]].

  5. #5
    New Member
    Join Date
    Apr 2011
    Location
    Chennai, Tamil Nadu, India
    Posts
    2

    Re: Country State City Lists

    I had been working with this for a while and i have created a snippet for myself. Here it is. You can copy the complete page and you can work it out for further usage. This applies to anybody who lands this page.

    http://vikku.info/programming/geodat...-hierarchy.htm

    Just view source that page and download all the includes in script tag. Thats it. I am further expanding my description so in due course of time there will be more information.

Posting Permissions

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



Click Here to Expand Forum to Full Width