Content Management Code

  Home arrow Content Management Code arrow Country List For Forms Using SQL
CONTENT MANAGEMENT CODE

Country List For Forms Using SQL
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2005-12-20

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    This simple snipt removes the mind blast of having to work with a select form of all country names (all 240 of them)!

    3/1/06 Edit: Removed duplicate DB entries

    Edit: Edited for a bit more clarity.

    By : LLX

    /*******in MYSQL*******/

    CREATE TABLE `CountryList` (
    `CountryID` int(11) NOT NULL auto_increment,
    `Name` varchar(200) NOT NULL default '',
    PRIMARY KEY (`CountryID`)
    ) TYPE=MyISAM AUTO_INCREMENT=242 ;

    --
    -- Dumping data for table `CountryList`
    --

    INSERT INTO `countrylist` VALUES (1, 'United States');
    INSERT INTO `countrylist` VALUES (2, 'Canada');
    INSERT INTO `countrylist` VALUES (3, 'Mexico');
    INSERT INTO `countrylist` VALUES (4, 'Afghanistan');
    INSERT INTO `countrylist` VALUES (5, 'Albania');
    INSERT INTO `countrylist` VALUES (6, 'Algeria');
    INSERT INTO `countrylist` VALUES (7, 'Andorra');
    INSERT INTO `countrylist` VALUES (8, 'Angola');
    INSERT INTO `countrylist` VALUES (9, 'Anguilla');
    INSERT INTO `countrylist` VALUES (10, 'Antarctica');
    INSERT INTO `countrylist` VALUES (11, 'Antigua and Barbuda');
    INSERT INTO `countrylist` VALUES (12, 'Argentina');
    INSERT INTO `countrylist` VALUES (13, 'Armenia');
    INSERT INTO `countrylist` VALUES (14, 'Aruba');
    INSERT INTO `countrylist` VALUES (15, 'Ascension Island');
    INSERT INTO `countrylist` VALUES (16, 'Australia');
    INSERT INTO `countrylist` VALUES (17, 'Austria');
    INSERT INTO `countrylist` VALUES (18, 'Azerbaijan');
    INSERT INTO `countrylist` VALUES (19, 'Bahamas');
    INSERT INTO `countrylist` VALUES (20, 'Bahrain');
    INSERT INTO `countrylist` VALUES (21, 'Bangladesh');
    INSERT INTO `countrylist` VALUES (22, 'Barbados');
    INSERT INTO `countrylist` VALUES (23, 'Belarus');
    INSERT INTO `countrylist` VALUES (24, 'Belgium');
    INSERT INTO `countrylist` VALUES (25, 'Belize');
    INSERT INTO `countrylist` VALUES (26, 'Benin');
    INSERT INTO `countrylist` VALUES (27, 'Bermuda');
    INSERT INTO `countrylist` VALUES (28, 'Bhutan');
    INSERT INTO `countrylist` VALUES (29, 'Bolivia');
    INSERT INTO `countrylist` VALUES (30, 'Bophuthatswana');
    INSERT INTO `countrylist` VALUES (31, 'Bosnia-Herzegovina');
    INSERT INTO `countrylist` VALUES (32, 'Botswana');
    INSERT INTO `countrylist` VALUES (33, 'Bouvet Island');
    INSERT INTO `countrylist` VALUES (34, 'Brazil');
    INSERT INTO `countrylist` VALUES (35, 'British Indian Ocean');
    INSERT INTO `countrylist` VALUES (36, 'British Virgin Islands');
    INSERT INTO `countrylist` VALUES (37, 'Brunei Darussalam');
    INSERT INTO `countrylist` VALUES (38, 'Bulgaria');
    INSERT INTO `countrylist` VALUES (39, 'Burkina Faso');
    INSERT INTO `countrylist` VALUES (40, 'Burundi');
    INSERT INTO `countrylist` VALUES (41, 'Cambodia');
    INSERT INTO `countrylist` VALUES (42, 'Cameroon');
    INSERT INTO `countrylist` VALUES (44, 'Cape Verde Island');
    INSERT INTO `countrylist` VALUES (45, 'Cayman Islands');
    INSERT INTO `countrylist` VALUES (46, 'Central Africa');
    INSERT INTO `countrylist` VALUES (47, 'Chad');
    INSERT INTO `countrylist` VALUES (48, 'Channel Islands');
    INSERT INTO `countrylist` VALUES (49, 'Chile');
    INSERT INTO `countrylist` VALUES (50, 'China, Peoples Republic');
    INSERT INTO `countrylist` VALUES (51, 'Christmas Island');
    INSERT INTO `countrylist` VALUES (52, 'Cocos (Keeling) Islands');
    INSERT INTO `countrylist` VALUES (53, 'Colombia');
    INSERT INTO `countrylist` VALUES (54, 'Comoros Islands');
    INSERT INTO `countrylist` VALUES (55, 'Congo');
    INSERT INTO `countrylist` VALUES (56, 'Cook Islands');
    INSERT INTO `countrylist` VALUES (57, 'Costa Rica');
    INSERT INTO `countrylist` VALUES (58, 'Croatia');
    INSERT INTO `countrylist` VALUES (59, 'Cuba');
    INSERT INTO `countrylist` VALUES (60, 'Cyprus');
    INSERT INTO `countrylist` VALUES (61, 'Czech Republic');
    INSERT INTO `countrylist` VALUES (62, 'Denmark');
    INSERT INTO `countrylist` VALUES (63, 'Djibouti');
    INSERT INTO `countrylist` VALUES (64, 'Dominica');
    INSERT INTO `countrylist` VALUES (65, 'Dominican Republic');
    INSERT INTO `countrylist` VALUES (66, 'Easter Island');
    INSERT INTO `countrylist` VALUES (67, 'Ecuador');
    INSERT INTO `countrylist` VALUES (68, 'Egypt');
    INSERT INTO `countrylist` VALUES (69, 'El Salvador');
    INSERT INTO `countrylist` VALUES (70, 'England');
    INSERT INTO `countrylist` VALUES (71, 'Equatorial Guinea');
    INSERT INTO `countrylist` VALUES (72, 'Estonia');
    INSERT INTO `countrylist` VALUES (73, 'Ethiopia');
    INSERT INTO `countrylist` VALUES (74, 'Falkland Islands');
    INSERT INTO `countrylist` VALUES (75, 'Faeroe Islands');
    INSERT INTO `countrylist` VALUES (76, 'Fiji');
    INSERT INTO `countrylist` VALUES (77, 'Finland');
    INSERT INTO `countrylist` VALUES (78, 'France');
    INSERT INTO `countrylist` VALUES (79, 'French Guyana');
    INSERT INTO `countrylist` VALUES (80, 'French Polynesia');
    INSERT INTO `countrylist` VALUES (81, 'Gabon');
    INSERT INTO `countrylist` VALUES (82, 'Gambia');
    INSERT INTO `countrylist` VALUES (83, 'Georgia Republic');
    INSERT INTO `countrylist` VALUES (84, 'Germany');
    INSERT INTO `countrylist` VALUES (85, 'Gibraltar');
    INSERT INTO `countrylist` VALUES (86, 'Greece');
    INSERT INTO `countrylist` VALUES (87, 'Greenland');
    INSERT INTO `countrylist` VALUES (88, 'Grenada');
    INSERT INTO `countrylist` VALUES (89, 'Guadeloupe (French)');
    INSERT INTO `countrylist` VALUES (90, 'Guatemala');
    INSERT INTO `countrylist` VALUES (91, 'Guernsey Island');
    INSERT INTO `countrylist` VALUES (92, 'Guinea Bissau');
    INSERT INTO `countrylist` VALUES (93, 'Guinea');
    INSERT INTO `countrylist` VALUES (94, 'Guyana');
    INSERT INTO `countrylist` VALUES (95, 'Haiti');
    INSERT INTO `countrylist` VALUES (96, 'Heard and McDonald Isls');
    INSERT INTO `countrylist` VALUES (97, 'Honduras');
    INSERT INTO `countrylist` VALUES (98, 'Hong Kong');
    INSERT INTO `countrylist` VALUES (99, 'Hungary');
    INSERT INTO `countrylist` VALUES (100, 'Iceland');
    INSERT INTO `countrylist` VALUES (101, 'India');
    INSERT INTO `countrylist` VALUES (102, 'Iran');
    INSERT INTO `countrylist` VALUES (103, 'Iraq');
    INSERT INTO `countrylist` VALUES (104, 'Ireland');
    INSERT INTO `countrylist` VALUES (105, 'Isle of Man');
    INSERT INTO `countrylist` VALUES (106, 'Israel');
    INSERT INTO `countrylist` VALUES (107, 'Italy');
    INSERT INTO `countrylist` VALUES (108, 'Ivory Coast');
    INSERT INTO `countrylist` VALUES (109, 'Jamaica');
    INSERT INTO `countrylist` VALUES (110, 'Japan');
    INSERT INTO `countrylist` VALUES (111, 'Jersey Island');
    INSERT INTO `countrylist` VALUES (112, 'Jordan');
    INSERT INTO `countrylist` VALUES (113, 'Kazakhstan');
    INSERT INTO `countrylist` VALUES (114, 'Kenya');
    INSERT INTO `countrylist` VALUES (115, 'Kiribati');
    INSERT INTO `countrylist` VALUES (116, 'Kuwait');
    INSERT INTO `countrylist` VALUES (117, 'Laos');
    INSERT INTO `countrylist` VALUES (118, 'Latvia');
    INSERT INTO `countrylist` VALUES (119, 'Lebanon');
    INSERT INTO `countrylist` VALUES (120, 'Lesotho');
    INSERT INTO `countrylist` VALUES (121, 'Liberia');
    INSERT INTO `countrylist` VALUES (122, 'Libya');
    INSERT INTO `countrylist` VALUES (123, 'Liechtenstein');
    INSERT INTO `countrylist` VALUES (124, 'Lithuania');
    INSERT INTO `countrylist` VALUES (125, 'Luxembourg');
    INSERT INTO `countrylist` VALUES (126, 'Macao');
    INSERT INTO `countrylist` VALUES (127, 'Macedonia');
    INSERT INTO `countrylist` VALUES (128, 'Madagascar');
    INSERT INTO `countrylist` VALUES (129, 'Malawi');
    INSERT INTO `countrylist` VALUES (130, 'Malaysia');
    INSERT INTO `countrylist` VALUES (131, 'Maldives');
    INSERT INTO `countrylist` VALUES (132, 'Mali');
    INSERT INTO `countrylist` VALUES (133, 'Malta');
    INSERT INTO `countrylist` VALUES (134, 'Martinique (French)');
    INSERT INTO `countrylist` VALUES (135, 'Mauritania');
    INSERT INTO `countrylist` VALUES (136, 'Mauritius');
    INSERT INTO `countrylist` VALUES (137, 'Mayotte');
    INSERT INTO `countrylist` VALUES (139, 'Micronesia');
    INSERT INTO `countrylist` VALUES (140, 'Moldavia');
    INSERT INTO `countrylist` VALUES (141, 'Monaco');
    INSERT INTO `countrylist` VALUES (142, 'Mongolia');
    INSERT INTO `countrylist` VALUES (143, 'Montenegro');
    INSERT INTO `countrylist` VALUES (144, 'Montserrat');
    INSERT INTO `countrylist` VALUES (145, 'Morocco');
    INSERT INTO `countrylist` VALUES (146, 'Mozambique');
    INSERT INTO `countrylist` VALUES (147, 'Myanmar');
    INSERT INTO `countrylist` VALUES (148, 'Namibia');
    INSERT INTO `countrylist` VALUES (149, 'Nauru');
    INSERT INTO `countrylist` VALUES (150, 'Nepal');
    INSERT INTO `countrylist` VALUES (151, 'Netherlands Antilles');
    INSERT INTO `countrylist` VALUES (152, 'Netherlands');
    INSERT INTO `countrylist` VALUES (153, 'New Caledonia (French)');
    INSERT INTO `countrylist` VALUES (154, 'New Zealand');
    INSERT INTO `countrylist` VALUES (155, 'Nicaragua');
    INSERT INTO `countrylist` VALUES (156, 'Niger');
    INSERT INTO `countrylist` VALUES (157, 'Niue');
    INSERT INTO `countrylist` VALUES (158, 'Norfolk Island');
    INSERT INTO `countrylist` VALUES (159, 'North Korea');
    INSERT INTO `countrylist` VALUES (160, 'Northern Ireland');
    INSERT INTO `countrylist` VALUES (161, 'Norway');
    INSERT INTO `countrylist` VALUES (162, 'Oman');
    INSERT INTO `countrylist` VALUES (163, 'Pakistan');
    INSERT INTO `countrylist` VALUES (164, 'Panama');
    INSERT INTO `countrylist` VALUES (165, 'Papua New Guinea');
    INSERT INTO `countrylist` VALUES (166, 'Paraguay');
    INSERT INTO `countrylist` VALUES (167, 'Peru');
    INSERT INTO `countrylist` VALUES (168, 'Philippines');
    INSERT INTO `countrylist` VALUES (169, 'Pitcairn Island');
    INSERT INTO `countrylist` VALUES (170, 'Poland');
    INSERT INTO `countrylist` VALUES (171, 'Polynesia (French)');
    INSERT INTO `countrylist` VALUES (172, 'Portugal');
    INSERT INTO `countrylist` VALUES (173, 'Qatar');
    INSERT INTO `countrylist` VALUES (174, 'Reunion Island');
    INSERT INTO `countrylist` VALUES (175, 'Romania');
    INSERT INTO `countrylist` VALUES (176, 'Russia');
    INSERT INTO `countrylist` VALUES (177, 'Rwanda');
    INSERT INTO `countrylist` VALUES (178, 'S.Georgia Sandwich Isls');
    INSERT INTO `countrylist` VALUES (179, 'Sao Tome, Principe');
    INSERT INTO `countrylist` VALUES (180, 'San Marino');
    INSERT INTO `countrylist` VALUES (181, 'Saudi Arabia');
    INSERT INTO `countrylist` VALUES (182, 'Scotland');
    INSERT INTO `countrylist` VALUES (183, 'Senegal');
    INSERT INTO `countrylist` VALUES (184, 'Serbia');
    INSERT INTO `countrylist` VALUES (185, 'Seychelles');
    INSERT INTO `countrylist` VALUES (186, 'Shetland');
    INSERT INTO `countrylist` VALUES (187, 'Sierra Leone');
    INSERT INTO `countrylist` VALUES (188, 'Singapore');
    INSERT INTO `countrylist` VALUES (189, 'Slovak Republic');
    INSERT INTO `countrylist` VALUES (190, 'Slovenia');
    INSERT INTO `countrylist` VALUES (191, 'Solomon Islands');
    INSERT INTO `countrylist` VALUES (192, 'Somalia');
    INSERT INTO `countrylist` VALUES (193, 'South Africa');
    INSERT INTO `countrylist` VALUES (194, 'South Korea');
    INSERT INTO `countrylist` VALUES (195, 'Spain');
    INSERT INTO `countrylist` VALUES (196, 'Sri Lanka');
    INSERT INTO `countrylist` VALUES (197, 'St. Helena');
    INSERT INTO `countrylist` VALUES (198, 'St. Lucia');
    INSERT INTO `countrylist` VALUES (199, 'St. Pierre Miquelon');
    INSERT INTO `countrylist` VALUES (200, 'St. Martins');
    INSERT INTO `countrylist` VALUES (201, 'St. Kitts Nevis Anguilla');
    INSERT INTO `countrylist` VALUES (202, 'St. Vincent Grenadines');
    INSERT INTO `countrylist` VALUES (203, 'Sudan');
    INSERT INTO `countrylist` VALUES (204, 'Suriname');
    INSERT INTO `countrylist` VALUES (205, 'Svalbard Jan Mayen');
    INSERT INTO `countrylist` VALUES (206, 'Swaziland');
    INSERT INTO `countrylist` VALUES (207, 'Sweden');
    INSERT INTO `countrylist` VALUES (208, 'Switzerland');
    INSERT INTO `countrylist` VALUES (209, 'Syria');
    INSERT INTO `countrylist` VALUES (210, 'Tajikistan');
    INSERT INTO `countrylist` VALUES (211, 'Taiwan');
    INSERT INTO `countrylist` VALUES (212, 'Tahiti');
    INSERT INTO `countrylist` VALUES (213, 'Tanzania');
    INSERT INTO `countrylist` VALUES (214, 'Thailand');
    INSERT INTO `countrylist` VALUES (215, 'Togo');
    INSERT INTO `countrylist` VALUES (216, 'Tokelau');
    INSERT INTO `countrylist` VALUES (217, 'Tonga');
    INSERT INTO `countrylist` VALUES (218, 'Trinidad and Tobago');
    INSERT INTO `countrylist` VALUES (219, 'Tunisia');
    INSERT INTO `countrylist` VALUES (220, 'Turkmenistan');
    INSERT INTO `countrylist` VALUES (221, 'Turks and Caicos Isls');
    INSERT INTO `countrylist` VALUES (222, 'Tuvalu');
    INSERT INTO `countrylist` VALUES (223, 'Uganda');
    INSERT INTO `countrylist` VALUES (224, 'Ukraine');
    INSERT INTO `countrylist` VALUES (225, 'United Arab Emirates');
    INSERT INTO `countrylist` VALUES (226, 'Uruguay');
    INSERT INTO `countrylist` VALUES (227, 'Uzbekistan');
    INSERT INTO `countrylist` VALUES (228, 'Vanuatu');
    INSERT INTO `countrylist` VALUES (229, 'Vatican City State');
    INSERT INTO `countrylist` VALUES (230, 'Venezuela');
    INSERT INTO `countrylist` VALUES (231, 'Vietnam');
    INSERT INTO `countrylist` VALUES (232, 'Virgin Islands (Brit)');
    INSERT INTO `countrylist` VALUES (233, 'Wales');
    INSERT INTO `countrylist` VALUES (234, 'Wallis Futuna Islands');
    INSERT INTO `countrylist` VALUES (235, 'Western Sahara');
    INSERT INTO `countrylist` VALUES (236, 'Western Samoa');
    INSERT INTO `countrylist` VALUES (237, 'Yemen');
    INSERT INTO `countrylist` VALUES (238, 'Yugoslavia');
    INSERT INTO `countrylist` VALUES (239, 'Zaire');
    INSERT INTO `countrylist` VALUES (240, 'Zambia');
    INSERT INTO `countrylist` VALUES (241, 'Zimbabwe');

    /****php call: dynamic select based on $_POST****/
    $ErrColor ="rgb(255,00,0)";
    $SfeColor ="rgb(51,153,255)";
    $SCNY = trim($_POST['x_ship_to_country']);

    echo'<TD valign=top><B>Country: </B></TD><TD valign=top colspan=5><SELECT size=1 name=x_ship_to_country style="background-color:'.$SfeColor.'">';
    $SHIPCountryQ = mysql_query("SELECT * FROM CountryList ORDER BY CountryID ASC")or die(mysql_error());
    while ($SHIPcheckCountry=mysql_fetch_assoc($SHIPCountryQ)){
    echo '<OPTION value="'.$SHIPcheckCountry['Name'].'"';
    if ($SCNY == $SHIPcheckCountry['Name']){
    echo ' SELECTED';
    };
    echo'>'.$SHIPcheckCountry['Name'].'</OPTION>';
    };// end while
    echo '</SELECT></TD>';


    /****inital form implemntation****/
    $BCNY = trim($_POST['x_country']);
    echo'<TD valign=top><B>Country: </B></TD><TD valign=top colspan=5><SELECT size=1 name=x_ship_to_country style="background-color:'.$SfeColor.'">';
    $SHIPCountryQ = mysql_query("SELECT * FROM CountryList ORDER BY CountryID ASC")or die(mysql_error());
    while ($SHIPcheckCountry=mysql_fetch_assoc($SHIPCountryQ)){
    echo '<OPTION value="'.$SHIPcheckCountry['Name'].'">'.$SHIPcheckCountry['Name'].'</OPTION>';
    };// end while
    echo '</SELECT></TD>';

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Content Management Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    CONTENT MANAGEMENT CODE ARTICLES

    - V2 CMS - Content Management System
    - VSNS Lemon
    - Country List For Forms Using SQL
    - eggblog
    - Table generation class
    - STP Simple Template Parser
    - class Vision_To_Form_Elements
    - Cascade Drop Down
    - Cura - CMS
    - Syntax Desktop
    - 216 color table
    - Simple Mini Poll class library (SimPoll)
    - Regex Generator
    - Siteseed
    - Company WebSite Builder PRO

    Developer Shed Affiliates

     



    © 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap