SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help getting data from multiple drop down lists

    Hi. I have a database called Europe and I want the user to select a country from a drop down list. Which I have done with the code below, but I then want the user to select a city from the databse, but only a city selected from the country selected in the first drop down box. Can someone tell me how I achieve this please thanks. This is what I have got so far

    <?php

    //Request the data from the europe databse
    $result = mysql_query('Select * FROM eu_place');
    if (!$result) {
    exit('<p>Error performing query: ' . mysql_error() . '</p>');
    }
    ?>

    <!--Select a country from the database-->
    <p> Select a country</p>
    <select name="country" size="1">
    <option selected value="">Select One</option>
    <option value="">------------</option>
    <?php

    while ($result = mysql_fetch_array($result)) {
    $country =$result['country'];
    echo "<option value='$country'>$country</option>\n";
    }
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    //Request the data from the europe databse
    $result mysql_query('Select * FROM eu_place');
    if (!
    $result) {
    exit(
    '<p>Error performing query: ' mysql_error() . '</p>');
    }
    ?>

    <!--Select a country from the database-->
    <p> Select a country</p>
    <select name="country[]" size="1" multiple="multiple">
    <option selected value="">Select One</option>
    <option value="">------------</option>
    <?php

    while ($result mysql_fetch_array($result)) {
    $country =$result['country'];
    echo 
    "<option value='$country'>$country</option>\n";
    }
    ?>
    Simply Sajan


Bookmarks

Posting Permissions

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