Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    drop down from data base

    Im trying to create a dropdown that is getting the infomation for a row in the database. i have this

    Code:
     <?php
    echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
    echo "</select>";
    ?>
    for example my db has a row with the countries name of "ZW (Zimbabwe)" in the database rcnitror_zipcode.countries.name

    database info = for more help
    Code:
    -- 
    -- Table structure for table `countries`
    -- 
    
    CREATE TABLE `countries` (
      `shortname` char(2) NOT NULL default '',
      `name` varchar(32) NOT NULL default ''
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    -- 
    -- Dumping data for table `countries`
    -- 
    
    INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
    INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
    INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
    INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
    INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
    INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
    INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
    INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
    INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
    INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
    INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
    INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
    INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
    INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
    INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
    INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
    INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
    INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
    INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
    INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
    INSERT INTO `countries` VALUES ('CM', 'Cameroon');
    INSERT INTO `countries` VALUES ('CA', 'Canada');
    INSERT INTO `countries` VALUES ('CV', 'Cape Verde');
    INSERT INTO `countries` VALUES ('KY', 'Cayman Islands');
    INSERT INTO `countries` VALUES ('CF', 'Central African Republic');
    INSERT INTO `countries` VALUES ('TD', 'Chad');
    INSERT INTO `countries` VALUES ('CL', 'Chile');
    INSERT INTO `countries` VALUES ('CN', 'China');
    INSERT INTO `countries` VALUES ('CX', 'Christmas Island');
    INSERT INTO `countries` VALUES ('CC', 'Cocos (Keeling) Islands');
    INSERT INTO `countries` VALUES ('CO', 'Colombia');
    INSERT INTO `countries` VALUES ('KM', 'Comoros');
    INSERT INTO `countries` VALUES ('CG', 'Congo');
    INSERT INTO `countries` VALUES ('CD', 'Congo, the Democratic Republic o');
    INSERT INTO `countries` VALUES ('CK', 'Cook Islands');
    INSERT INTO `countries` VALUES ('CR', 'Costa Rica');
    INSERT INTO `countries` VALUES ('HR', 'Croatia');
    INSERT INTO `countries` VALUES ('CY', 'Cyprus');
    INSERT INTO `countries` VALUES ('CZ', 'Czech Republic');
    INSERT INTO `countries` VALUES ('AF', 'Afghanistan');
    INSERT INTO `countries` VALUES ('AF', 'Afghanistan');
    INSERT INTO `countries` VALUES ('AL', 'Albania');
    INSERT INTO `countries` VALUES ('DZ', 'Algeria');
    INSERT INTO `countries` VALUES ('AS', 'American Samoa');
    INSERT INTO `countries` VALUES ('AD', 'Andorra');
    INSERT INTO `countries` VALUES ('AO', 'Angola');
    INSERT INTO `countries` VALUES ('AI', 'Anguilla');
    INSERT INTO `countries` VALUES ('AG', 'Antigua and Barbuda');
    INSERT INTO `countries` VALUES ('AR', 'Argentina');
    INSERT INTO `countries` VALUES ('AM', 'Armenia');
    INSERT INTO `countries` VALUES ('AW', 'Aruba');
    INSERT INTO `countries` VALUES ('AU', 'Australia');
    INSERT INTO `countries` VALUES ('AT', 'Austria');
    INSERT INTO `countries` VALUES ('AZ', 'Azerbaijan');
    INSERT INTO `countries` VALUES ('BS', 'Bahamas');
    INSERT INTO `countries` VALUES ('BH', 'Bahrain');
    INSERT INTO `countries` VALUES ('BD', 'Bangladesh');
    INSERT INTO `countries` VALUES ('BB', 'Barbados');
    INSERT INTO `countries` VALUES ('BY', 'Belarus');
    INSERT INTO `countries` VALUES ('BE', 'Belgium');
    INSERT INTO `countries` VALUES ('BZ', 'Belize');
    INSERT INTO `countries` VALUES ('BJ', 'Benin');
    INSERT INTO `countries` VALUES ('BM', 'Bermuda');
    INSERT INTO `countries` VALUES ('BT', 'Bhutan');
    INSERT INTO `countries` VALUES ('BO', 'Bolivia');
    INSERT INTO `countries` VALUES ('BW', 'Botswana');
    INSERT INTO `countries` VALUES ('BA', 'Boznia and Herzegovina');
    INSERT INTO `countries` VALUES ('BR', 'Brazil');
    INSERT INTO `countries` VALUES ('BN', 'Brunei Darussalam');
    INSERT INTO `countries` VALUES ('BG', 'Bulgaria');
    INSERT INTO `countries` VALUES ('BF', 'Burkina Faso');
    INSERT INTO `countries` VALUES ('BI', 'Burundi');
    INSERT INTO `countries` VALUES ('KH', 'Cambodia');
    INSERT INTO `countries` VALUES ('CM', 'Cameroon');
    INSERT INTO `countries` VALUES ('CA', 'Canada');
    INSERT INTO `countries` VALUES ('CV', 'Cape Verde');
    INSERT INTO `countries` VALUES ('KY', 'Cayman Islands');
    INSERT INTO `countries` VALUES ('CF', 'Central African Republic');
    INSERT INTO `countries` VALUES ('TD', 'Chad');
    INSERT INTO `countries` VALUES ('CL', 'Chile');
    INSERT INTO `countries` VALUES ('CN', 'China');
    INSERT INTO `countries` VALUES ('CX', 'Christmas Island');
    INSERT INTO `countries` VALUES ('CC', 'Cocos (Keeling) Islands');
    INSERT INTO `countries` VALUES ('CO', 'Colombia');
    INSERT INTO `countries` VALUES ('KM', 'Comoros');
    INSERT INTO `countries` VALUES ('CG', 'Congo');
    INSERT INTO `countries` VALUES ('CD', 'Congo, the Democratic Republic o');
    INSERT INTO `countries` VALUES ('CK', 'Cook Islands');
    INSERT INTO `countries` VALUES ('CR', 'Costa Rica');
    INSERT INTO `countries` VALUES ('HR', 'Croatia');
    INSERT INTO `countries` VALUES ('CY', 'Cyprus');
    INSERT INTO `countries` VALUES ('CZ', 'Czech Republic');
    INSERT INTO `countries` VALUES ('BR', 'Brazil');
    INSERT INTO `countries` VALUES ('BN', 'Brunei Darussalam');
    INSERT INTO `countries` VALUES ('BG', 'Bulgaria');
    INSERT INTO `countries` VALUES ('BF', 'Burkina Faso');
    INSERT INTO `countries` VALUES ('BI', 'Burundi');
    INSERT INTO `countries` VALUES ('KH', 'Cambodia');
    INSERT INTO `countries` VALUES ('CM', 'Cameroon');
    INSERT INTO `countries` VALUES ('CA', 'Canada');
    INSERT INTO `countries` VALUES ('CV', 'Cape Verde');
    INSERT INTO `countries` VALUES ('KY', 'Cayman Islands');
    INSERT INTO `countries` VALUES ('CF', 'Central African Republic');
    INSERT INTO `countries` VALUES ('TD', 'Chad');
    INSERT INTO `countries` VALUES ('CL', 'Chile');
    INSERT INTO `countries` VALUES ('CN', 'China');
    INSERT INTO `countries` VALUES ('CX', 'Christmas Island');
    INSERT INTO `countries` VALUES ('CC', 'Cocos (Keeling) Islands');
    INSERT INTO `countries` VALUES ('CO', 'Colombia');
    INSERT INTO `countries` VALUES ('KM', 'Comoros');
    INSERT INTO `countries` VALUES ('CG', 'Congo');
    INSERT INTO `countries` VALUES ('CD', 'Congo, the Democratic Republic o');
    INSERT INTO `countries` VALUES ('CK', 'Cook Islands');
    INSERT INTO `countries` VALUES ('CR', 'Costa Rica');
    INSERT INTO `countries` VALUES ('HR', 'Croatia');
    INSERT INTO `countries` VALUES ('CY', 'Cyprus');
    INSERT INTO `countries` VALUES ('CZ', 'Czech Republic');
    INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
    INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
    INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
    INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
    INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
    INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
    INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
    INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
    INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
    INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
    INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
    INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
    INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
    INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
    INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
    INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
    INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
    INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
    INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
    INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
    INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
    INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
    INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
    INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
    INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
    INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
    INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
    INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
    INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
    INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
    INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
    INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
    INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
    INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
    INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
    INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
    INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
    INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
    INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
    INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
    INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
    INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
    INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
    INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
    INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
    INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
    INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
    INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
    INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
    INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
    INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
    INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
    INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
    INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
    INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
    INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
    INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
    INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
    INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
    INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
    INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
    INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
    INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
    INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
    INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
    INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
    INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
    INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
    INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
    INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
    INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
    INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
    INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
    INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
    INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
    INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
    INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
    INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
    INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
    INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
    INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
    INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
    INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
    INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
    INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
    INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
    INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
    INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
    INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
    INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
    INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
    INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
    INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
    INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
    INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
    INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
    INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
    INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
    INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
    INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
    INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
    INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
    INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
    INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
    INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
    INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
    INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
    INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
    INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
    INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
    INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
    INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
    INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
    INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
    INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
    INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
    INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
    INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
    INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
    INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
    INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
    INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
    INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
    INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
    INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
    INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
    INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
    INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
    INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
    INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
    INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
    INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
    INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
    INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
    INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
    INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
    INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
    INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
    INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
    INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
    INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
    INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
    INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
    INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
    INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
    INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
    INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
    INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
    INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
    INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
    INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
    INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
    INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
    INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
    INSERT INTO `countries` VALUES ('AW', 'AW (Aruba)');
    INSERT INTO `countries` VALUES ('AZ', 'AZ (Azerbaijan)');
    INSERT INTO `countries` VALUES ('BA', 'BA (Bosnia and Herzegovina)');
    INSERT INTO `countries` VALUES ('BB', 'BB (Barbados)');
    INSERT INTO `countries` VALUES ('BD', 'BD (Bangladesh)');
    INSERT INTO `countries` VALUES ('BE', 'BE (Belgium)');
    INSERT INTO `countries` VALUES ('BF', 'BF (Burkina Faso)');
    INSERT INTO `countries` VALUES ('BG', 'BG (Bulgaria)');
    INSERT INTO `countries` VALUES ('BH', 'BH (Bahrain)');
    INSERT INTO `countries` VALUES ('BI', 'BI (Burundi)');
    INSERT INTO `countries` VALUES ('BJ', 'BJ (Benin)');
    INSERT INTO `countries` VALUES ('BM', 'BM (Bermuda)');
    INSERT INTO `countries` VALUES ('BN', 'BN (Brunei Darussalam)');
    INSERT INTO `countries` VALUES ('BO', 'BO (Bolivia)');
    INSERT INTO `countries` VALUES ('BR', 'BR (Brazil)');
    INSERT INTO `countries` VALUES ('BS', 'BS (Bahamas)');
    INSERT INTO `countries` VALUES ('BT', 'BT (Bhutan)');
    INSERT INTO `countries` VALUES ('BV', 'BV (Bouvet Island)');
    INSERT INTO `countries` VALUES ('BW', 'BW (Botswana)');
    INSERT INTO `countries` VALUES ('BY', 'BY (Belarus)');
    INSERT INTO `countries` VALUES ('BZ', 'BZ (Belize)');
    INSERT INTO `countries` VALUES ('CA', 'CA (Canada)');
    INSERT INTO `countries` VALUES ('CC', 'CC (Cocos (Keeling) Islands)');
    INSERT INTO `countries` VALUES ('CF', 'CF (Central African Republic)');
    INSERT INTO `countries` VALUES ('CG', 'CG (Congo)');
    INSERT INTO `countries` VALUES ('CH', 'CH (Switzerland)');
    INSERT INTO `countries` VALUES ('AD', 'AD (Andorra)');
    INSERT INTO `countries` VALUES ('AE', 'AE (United Arab Emirates)');
    INSERT INTO `countries` VALUES ('AF', 'AF (Afghanistan)');
    INSERT INTO `countries` VALUES ('AG', 'AG (Antigua and Barbuda)');
    INSERT INTO `countries` VALUES ('AI', 'AI (Anguilla)');
    INSERT INTO `countries` VALUES ('AL', 'AL (Albania)');
    INSERT INTO `countries` VALUES ('AM', 'AM (Armenia)');
    INSERT INTO `countries` VALUES ('AN', 'AN (Netherlands Antilles)');
    INSERT INTO `countries` VALUES ('AO', 'AO (Angola)');
    INSERT INTO `countries` VALUES ('AQ', 'AQ (Antarctica)');
    INSERT INTO `countries` VALUES ('AR', 'AR (Argentina)');
    INSERT INTO `countries` VALUES ('AS', 'AS (American Samoa)');
    INSERT INTO `countries` VALUES ('AT', 'AT (Austria)');
    INSERT INTO `countries` VALUES ('AU', 'AU (Australia)');
    
    
    + more
    Last edited by bigredkacy; 06-09-2005 at 06:21 AM.

  • #2
    New Coder
    Join Date
    Jun 2005
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You mean something like:

    options = array();
    query database
    while database results (fetch_assoc)
    options[] = <option value="shortname">name</option>
    $string = implode('',options);

    try working the above into real php and post back if stuck somewhere.

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i dont understand sorry :*(

    can you like fill it in with like the info and ill edit the db info or what?

  • #4
    New Coder
    Join Date
    Jun 2005
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://us4.php.net/mysql_query
    $result = mysql_query('select * from countries');
    $_cOptions = array();
    while($row = mysql_fetch_assoc($result)) {
    $_cOptions[] = "<option value=\"{$row['shortname']}\">{$row['name']}</option>";
    }
    $cOptions = implode("\n",$_cOptions);

    <?php
    echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
    echo $cOptions;
    echo "</select>";
    ?>

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Location
    Tokyo, Japan
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you want to do something like this...

    I assume that you have already extablished the connection to the db.

    after the connection is made you need to query the database and store the values in a resultset:
    PHP Code:

    $select 
    "SELECT name FROM countries ORDER BY name";

    //the result of the query will be stored here
    $rs mysql_query($select) or die(mysql_error()); 
    Then you have to "echo" the .html that will construct the <select> menu.
    Note: the "while" loop will iterate through the result set and create a new <option> for each row:

    PHP Code:

    echo "<label>Please select your country: ";
        echo 
    "<select name='country' id='country'>";


        
    //Each row in the rs will be an option
        
    while ($row mysql_fetch_array($rs)) 
            {
                echo 
    "<option value='".$row['name']."'>".$row['name']."</option>";
            }
    }

    //this closes the open .html tags
    echo "</label>";
    echo 
    "</select>";
    echo 
    "</form>"
    After that it's also a good idea to clear the result set and close the db:

    PHP Code:

    //free memory
    mysql_free_result($rs);

    //close the db
    mysql_close(); 

    Hope that helps.

    Yak

  • #6
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    and all this can go into my one php file?

    heres the code

    Code:
    <?php
        if(isset($_GET['submit'])){
            mysql_connect("localhost", "rcnitror_kacy", "");
            mysql_select_db("rcnitror_zipcode");
    $query = "insert into dealers(`address1`,`country`,`name`,`phone`,`url`,`fulltime`,`onroad`,`offroad`,`fax`,`email`,`zip`,`hours`,`carry`,`order`) values ('".$_GET["Address1"]."','".$_GET["Country"]."','".$_GET["Name"]."','".$_GET["Phone"]."','".$_GET["URL"]."','".$_GET["fulltime"]."','".$_GET["onroad"]."','".$_GET["offroad"]."','".$_GET["Fax"]."','".$_GET["Email"]."','".$_GET["Zip"]."','".$_GET["hours"]."','".$_GET["carry"]."','".$_GET['order']."')";
    mysql_query($query) or die(mysql_error());
            if(!$query){
                echo "Sorry but there was an error when processing your request. Please try again. " . mysql_error();
            }
            else
            {
                echo "Success! <a href='search.html'>Return to search</a>";
            }
        }
        else
        {
    ?>
    <body>
        <form action='adddealer.php' method='get'>
    <?php
    echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
    echo "</select>";
    ?>
    <br>  
            Dealer Name:        <input type='text' name='Name'><br>
            Hours:              <input type='text' name='Hours'><br>
            Telephone Number:   <input type='text' name='Phone'><br>
            Fax Number:         <input type='text' name='Fax'><br>
            Email Address:      <input type='text' name='Email'><br>
            Website:            <input type='text' name='URL'><br>
            Postcode:           <input type='text' name='Zip'><br>
            Address:           <input type='text' name='Address1'><br>
            Full time hobby shop:
                <input type='radio' name='fulltime' value='yes'>Yes
                <input type='radio' name='fulltime' value='No'>No<br>
            On-road track:
                <input type='radio' name='onroad' value='Yes'>Yes
                <input type='radio' name='onroad' value='No'>No<br>
            Off-road track:
                <input type='radio' name='offroad' value='Yes'>Yes
                <input type='radio' name='offroad' value='No'>No<br>
            Carry Integy parts in stock:
                <input type='radio' name='carry' value='Yes'>Yes
                <input type='radio' name='carry' value='No'>No<br>
            Special order Integy parts:
                <input type='radio' name='order' value='Yes'>Yes
                <input type='radio' name='order' value='no'>No<br>
    
            <input type='submit' name='submit'>
    </form>
    </body>
    </html>
    
    <?php } ?>
    is there anyway you can insert it in there. i dont know how in notpad

  • #7
    Regular Coder
    Join Date
    Feb 2005
    Location
    Tokyo, Japan
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes. The best way to insert it in there (notepad) is to cut and paste the code to the spot where you want the button to appear.

    It would look something like this:

    Code:
    <?php
        if(isset($_GET['submit'])){
            mysql_connect("localhost", "XXXXXXX", "XXXXXX");
            mysql_select_db("rcnitror_zipcode");
    $query = "insert into dealers(`address1`,`country`,`name`,`phone`,`url`,`fulltime`,`onroad`,`offroad`,`fax`,`email`,`zip`,  `hours`,`carry`,`order`) values ('".$_GET["Address1"]."','".$_GET["Country"]."','".$_GET["Name"]."','".$_GET["Phone"]."','".$_GET["URL"]."','".$_GET["fulltime"]."','".$_GET["onroad"]."','".$_GET["offroad"]."','".$_GET["Fax"]."','".$_GET["Email"]."','".$_GET["Zip"]."','".$_GET["hours"]."','".$_GET["carry"]."','".$_GET['order']."')";
    mysql_query($query) or die(mysql_error());
            if(!$query){
                echo "Sorry but there was an error when processing your request. Please try again. " . mysql_error();
            }
            else
            {
                echo "Success! <a href='search.html'>Return to search</a>";
            }
        }
        else
        {
    ?>
    <body>
        <form action='adddealer.php' method='get'>
    <?php
    
    $select = "SELECT name FROM countries ORDER BY name";
    
    //the result of the query will be stored here
    $rs = mysql_query($select) or die(mysql_error()); 
    
     echo "<label>Please select your country: ";
        echo "<select name='country' id='country'>";
    
    
        //Each row in the rs will be an option
        while ($row = mysql_fetch_array($rs)) 
            {
                echo "<option value='".$row['name']."'>".$row['name']."</option>";
            }
    }
    
    //this closes the open .html tags
    echo "</label>";
    echo "</select>";
    echo "</form>"; 
    
    echo "Select Your Country <select name='Country'><option value='Select your country' SELECTED>Select your country</option>";
    echo "</select>";
    ?>
    <br>  
            Dealer Name:        <input type='text' name='Name'><br>
            Hours:              <input type='text' name='Hours'><br>
            Telephone Number:   <input type='text' name='Phone'><br>
            Fax Number:         <input type='text' name='Fax'><br>
            Email Address:      <input type='text' name='Email'><br>
            Website:            <input type='text' name='URL'><br>
            Postcode:           <input type='text' name='Zip'><br>
            Address:           <input type='text' name='Address1'><br>
            Full time hobby shop:
                <input type='radio' name='fulltime' value='yes'>Yes
                <input type='radio' name='fulltime' value='No'>No<br>
            On-road track:
                <input type='radio' name='onroad' value='Yes'>Yes
                <input type='radio' name='onroad' value='No'>No<br>
            Off-road track:
                <input type='radio' name='offroad' value='Yes'>Yes
                <input type='radio' name='offroad' value='No'>No<br>
            Carry Integy parts in stock:
                <input type='radio' name='carry' value='Yes'>Yes
                <input type='radio' name='carry' value='No'>No<br>
            Special order Integy parts:
                <input type='radio' name='order' value='Yes'>Yes
                <input type='radio' name='order' value='no'>No<br>
    
            <input type='submit' name='submit'>
    </form>
    </body>
    </html>
    
    <?php 
    
     //free memory
    mysql_free_result($rs);
    
    //close the db
    mysql_close();  
    
     ?>
    Yak
    Last edited by Yakisoba; 06-10-2005 at 04:11 AM.

  • #8
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i did this now its duplicating the field... www.rcnitroracing.com/zipcode/adddealer.php
    anything?

    Code:
    <?php
        if(isset($_GET['submit'])){
            mysql_connect("localhost", "rcnitror_kacy", "k");
            mysql_select_db("rcnitror_zipcode");
    $query = "insert into dealers(`address1`,`country`,`name`,`phone`,`url`,`fulltime`,`onroad`,`offroad`,`fax`,`email`,`zip`,    `hours`,`carry`,`order`) values ('".$_GET["Address1"]."','".$_GET["Country"]."','".$_GET["Name"]."','".$_GET["Phone"]."','".$_GET["URL"]."','".$_GET["fulltime"]."','".$_GET["onroad"]."','".$_GET["offroad"]."','".$_GET["Fax"]."','".$_GET["Email"]."','".$_GET["Zip"]."','".$_GET["hours"]."','".$_GET["carry"]."','".$_GET['order']."')";
    mysql_query($query) or die(mysql_error());
            if(!$query){
                echo "Sorry but there was an error when processing your request. Please try again. " . mysql_error();
            }
            else
            {
                echo "Success! <a href='search.html'>Return to search</a>";
            }
        }
        else
        {
    ?>
    <body>
        <form action='adddealer.php' method='get'>
    <?php
            mysql_connect("localhost", "rcnitror_kacy", "k");
            mysql_select_db("rcnitror_zipcode");
    $select = "SELECT name FROM countries ORDER BY name";
    
    //the result of the query will be stored here
    $rs = mysql_query($select) or die(mysql_error()); 
    
     echo "<label>Please select your country: ";
        echo "<select name='country' id='country'>";
    
    
        //Each row in the rs will be an option
        while ($row = mysql_fetch_assoc($rs)) 
            {
                echo "<option value='".$row['name']."'>".$row['name']."</option>";
            }
    }
    
    //this closes the open .html tags
    echo "</label>";
    echo "</select>";
    echo "</form>"; 
    ?>
    <br>  
            Dealer Name:        <input type='text' name='Name'><br>
            Hours:              <input type='text' name='Hours'><br>
            Telephone Number:   <input type='text' name='Phone'><br>
            Fax Number:         <input type='text' name='Fax'><br>
            Email Address:      <input type='text' name='Email'><br>
            Website:            <input type='text' name='URL'><br>
            Postcode:           <input type='text' name='Zip'><br>
            Address:           <input type='text' name='Address1'><br>
            Full time hobby shop:
                <input type='radio' name='fulltime' value='yes'>Yes
                <input type='radio' name='fulltime' value='No'>No<br>
            On-road track:
                <input type='radio' name='onroad' value='Yes'>Yes
                <input type='radio' name='onroad' value='No'>No<br>
            Off-road track:
                <input type='radio' name='offroad' value='Yes'>Yes
                <input type='radio' name='offroad' value='No'>No<br>
            Carry Integy parts in stock:
                <input type='radio' name='carry' value='Yes'>Yes
                <input type='radio' name='carry' value='No'>No<br>
            Special order Integy parts:
                <input type='radio' name='order' value='Yes'>Yes
                <input type='radio' name='order' value='no'>No<br>
    
            <input type='submit' name='submit'>
    </form>
    </body>
    </html>
    
    <?php 
    
     //free memory
    mysql_free_result($rs);
    
    //close the db
    mysql_close();  
    
     ?>

  • #9
    Regular Coder
    Join Date
    Feb 2005
    Location
    Tokyo, Japan
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I don't quite understand the question...

    What field is duplicating?

    I went to your link...the drop-down menu appears fine.

    Yak

    Also - not sure if you mind, but, you might want to remove your DB login and password from the code you post(ed).
    Last edited by Yakisoba; 06-10-2005 at 04:10 AM.

  • #10
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got it. THANKS SO MUCH FOR THE HELP.... <3


  •  

    Posting Permissions

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