35 users online (2 members and 33 guests)  


  Results 1 to 5 of 5

Related

  1. Need help with MySQL fetch    Forum: Databases
    Replies: 2
  2. array problems    Forum: PHP Forum
    Replies: 1
  3. mysql fetch array error please help    Forum: PHP Forum
    Replies: 10
  4. Dynamic JS Array Problems in IE6    Forum: Javascript Forum
    Replies: 0
  5. php - fetch array error    Forum: PHP Forum
    Replies: 4
  1. #1
    pcross's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    6

    Unhappy fetch array problems

    First, I am new to this site/forum and somewhat familiar with PHP.

    I am attempting to modify a database and it's functions from a project that I had a company develop (nearly 3 yrs ago.) - I thought this would be simple. (wrong?)

    This is what I am trying to accomplish.
    db consists of one table and 23 fileds.
    It is a list of locations with their info.

    I want to have it retrieve a list of cities within a State & Country or if no State then just Country.
    Further, the city must be a select option in a form.
    PHP Code:
    <?php
    if (($country == "USA" || $country == "Canada") && $state == "")
    {
        
    redirect("<br><br>You need to select the state/province first. Taking you to the state selection area.","?action=selectState&country=$country");
    }
    if (
    $country == "USA" || $country == "Canada")
    echo 
    "<center><br>State: &nbsp;".$states[$state].", $country</font>";
    echo 
    "<FORM action='?action=display' method=post>
          <INPUT TYPE='hidden' NAME='country' VALUE='
    $country'>
          <INPUT TYPE='hidden' NAME='state' VALUE='
    $state'>";
     if (
    $country == "USA" || $country == "Canada" && $states == "$state")
       { 
       
    $citydb1 mysql_query("SELECT city FROM db WHERE state='$state', country='$country' ORDER BY city ASC");
        
    $cities mysql_fetch_array($citydb1);
        }
     else 
       { 
       
    $citydb2 mysql_query("SELECT city FROM db WHERE country='$country' ORDER BY city ASC");
        
    $cities mysql_fetch_array($citydb2);
        };
    echo 
    "<select name='city'>
    <option value='
    $cities'>$cities</option></FORM><br>";
    ?>
    I am certain I am missing not only the loop [while] but something else?

    Any ideas or suggestions.

  2. #2
    pcross's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    6

    Question

    I have attempted several times and several ways to make this function. All to no avail.

    Does anyone have an idea of how to get this to function?

    Many thanx

  3. #3
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    I am sorry nobody has been able to help you. Hopefully you have solved your problem by now?

    Dave

  4. #4
    pcross's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    6
    Not really - I am hiring a database developer to assist me though...

    Oh well, I appreciate the place to ask... I will check in time to time...

    Many thanx

  5. #5
    Najjar's Avatar
    New User

    Status
    Offline
    Join Date
    May 2004
    Posts
    2
    Can you be more specific on whats the problem
    and can you show me the error you are getting.



Tags for this Thread