Thursday, June 13

Finding country and its phone code using php and jquery.

Hi All,
Here I write a program for finding country and its phone code using php and jquery.


<?php
$countries = array("af" => "Afghanistan", "ax" => "Aland Islands", "al" => "Albania", "dz" => "Algeria", "as" => "American Samoa",
    "ad" => "Andorra", "ao" => "Angola", "ai" => "Anguilla", "aq" => "Antarctica", "ag" => "Antigua and Barbuda", "ar" => "Argentina",
    "am" => "Armenia", "aw" => "Aruba", "au" => "Australia", "at" => "Austria", "az" => "Azerbaijan", "bs" => "Bahamas", "bh" => "Bahrain",
    "bd" => "Bangladesh", "bb" => "Barbados", "by" => "Belarus", "be" => "Belgium", "bz" => "Belize", "bj" => "Benin", "bm" => "Bermuda",
    "bt" => "Bhutan", "bo" => "Bolivia", "ba" => "Bosnia and Herzegovina", "bw" => "Botswana", "bv" => "Bouvet Island", "br" => "Brazil",
    "io" => "British Indian Ocean Territory", "vg" => "British Virgin Islands", "bn" => "Brunei", "bg" => "Bulgaria",
    "bf" => "Burkina Faso", "bi" => "Burundi", "kh" => "Cambodia", "cm" => "Cameroon", "ca" => "Canada", "cv" => "Cape Verde",
    "ky" => "Cayman Islands", "cf" => "Central African Republic", "td" => "Chad", "cl" => "Chile", "cn" => "China",
    "cx" => "Christmas Island", "cc" => "Cocos Island", "co" => "Colombia", "km" => "Comoros", "cg" => "Congo",
    "cd" => "Congo, Democratic Republic of", "ck" => "Cook Islands", "cr" => "Costa Rica", "ci" => "C&ocirc;te d'Ivoire",
    "hr" => "Croatia", "cu" => "Cuba", "cy" => "Cyprus", "cz" => "Czech Republic", "dk" => "Denmark", "xx" => "Disputed Territory",
    "dj" => "Djibouti", "dm" => "Dominica", "do" => "Dominican Republic", "ec" => "Ecuador", "eg" => "Egypt", "sv" => "El Salvador",
    "gq" => "Equatorial Guinea", "er" => "Eritrea", "ee" => "Estonia", "et" => "Ethiopia", "fk" => "Falkland Islands",
    "fo" => "Faroe Islands", "fj" => "Fiji", "fi" => "Finland", "fr" => "France", "gf" => "French Guiana", "pf" => "French Polynesia",
    "tf" => "French Southern Territories", "ga" => "Gabon", "gm" => "Gambia", "ge" => "Georgia", "de" => "Germany", "gh" => "Ghana",
    "gi" => "Gibraltar", "gr" => "Greece", "gl" => "Greenland", "gd" => "Grenada", "gp" => "Guadeloupe", "gu" => "Guam", "gt" => "Guatemala",
    "gg" => "Guernsey", "gn" => "Guinea", "gw" => "Guinea-Bissau", "gy" => "Guyana", "ht" => "Haiti",
    "hm" => "Heard Islands and McDonald Islands", "hn" => "Honduras", "hk" => "Hong Kong", "hu" => "Hungary", "is" => "Iceland",
    "in" => "India", "id" => "Indonesia", "ir" => "Iran", "iq" => "Iraq", "xe" => "Iraq-Saudi Arabia Neutral Zone", "ie" => "Ireland",
    "im" => "Isle of Man", "il" => "Israel", "it" => "Italy", "ci" => "Ivory Coast", "jm" => "Jamaica", "jp" => "Japan", "je" => "Jersey",
    "jo" => "Jordan", "kz" => "Kazakhstan", "ke" => "Kenya", "ki" => "Kiribati", "kw" => "Kuwait", "kg" => "Kyrgyzstan", "la" => "Laos",
    "lv" => "Latvia", "lb" => "Lebanon", "ls" => "Lesotho", "lr" => "Liberia", "ly" => "Libya", "li" => "Liechtenstein", "lt" => "Lithuania",
    "lu" => "Luxembourg", "mo" => "Macao", "mk" => "Macedonia", "mg" => "Madagascar", "mw" => "Malawi", "my" => "Malaysia", "mv" => "Maldives",
    "ml" => "Mali", "mt" => "Malta", "mh" => "Marshall Islands", "mg" => "Martinique", "mr" => "Mauritania", "mu" => "Mauritius",
    "yt" => "Mayotte", "mx" => "Mexico", "fm" => "Micronesia", "md" => "Moldova", "mc" => "Monaco", "mn" => "Mongolia", "me" => "Montenegro",
    "ms" => "Montserrat", "ma" => "Morocco", "mz" => "Mozambique", "mm" => "Myanmar", "na" => "Namibia", "nr" => "Nauru", "np" => "Nepal",
    "nl" => "Netherlands", "an" => "Netherlands Antilles", "nc" => "New Caledonia", "nz" => "New Zealand", "ni" => "Nicaragua",
    "ne" => "Niger", "ng" => "Nigeria", "nu" => "Niue", "nf" => "Norfolk Island", "mp" => "Northern Mariana Islands", "kp" => "North Korea",
    "no" => "Norway", "om" => "Oman", "pk" => "Pakistan", "pw" => "Palau", "ps" => "Palestinian Territory", "pa" => "Panama",
    "pg" => "Papua New Guinea", "py" => "Paraguay", "pe" => "Peru", "ph" => "Philippines", "pn" => "Pitcairn Islands", "pl" => "Poland",
    "pt" => "Portugal", "pr" => "Puerto Rico", "qa" => "Qatar", "re" => "Reunion", "ro" => "Romania", "ru" => "Russia", "rw" => "Rwanda",
    "sh" => "Saint Helena", "kn" => "Saint Kitts and Nevis", "lc" => "Sant Lucia", "pm" => "Saint Pierre and Miquelon",
    "vc" => "Sant Vincent and the Grenadines", "ws" => "Samoa", "sm" => "San Marino",
    "st" => "S&atilde;p Tom&eacute; and Pr&iacute;ncipe", "sa" => "Saudi Arabia", "sn" => "Senegal", "rs" => "Serbia",
    "cs" => "Serbia and Montenegro", "sc" => "Seychelles", "sl" => "Sierra Leone", "sg" => "Singapore", "sk" => "Slovakia",
    "si" => "Slovenia", "sb" => "Solomon Islands", "so" => "Somalia", "za" => "South Africa",
    "gs" => "South Georgia and the South Sandwich Islands", "kr" => "South Korea", "es" => "Spain", "lk" => "Sri Lanka", "sd" => "Sudan",
    "sr" => "Suriname", "sj" => "Svalbard and Jan Mayen Islands", "sz" => "Swaziland", "se" => "Sweden", "ch" => "Switzerland",
    "sy" => "Syria", "tw" => "Taiwan", "tj" => "Tajikistan", "tz" => "Tanzania", "th" => "Thailand", "tl" => "Timor-Leste", "tg" => "Togo",
    "tk" => "Tokelau", "to" => "Tonga", "tt" => "Trinidad and Tobago", "tn" => "Tunisia", "tr" => "Turkey", "tm" => "Turkmenistan",
    "tc" => "Turks and Caicos Islands", "tv" => "Tuvalu", "ug" => "Uganda", "ua" => "Ukraine", "ae" => "United Arab Emirates",
    "uk" => "United Kingdom", "xd" => "United Nations Neutral Zone", "us" => "United States",
    "um" => "United States Minor Outlying Islands", "vi" => "U.S. Virgin Islands", "uy" => "Uruguay", "uz" => "Uzbekistan",
    "vu" => "Vanuatu", "va" => "Vatican City", "ve" => "Venezuela", "vn" => "Vietnam", "wf" => "Wallis and Futuna Islands",
    "eh" => "Western Sahara", "ye" => "Yemen", "zm" => "Zambia", "zw" => "Zimbabwe");
?>
<script>
    var countryCodeList = new Array();
    countryCodeList['AX'] = '358';
    countryCodeList['AF'] = '93';
    countryCodeList['AL'] = '355';
    countryCodeList['DZ'] = '213';
    countryCodeList['AS'] = '684';
    countryCodeList['AD'] = '376';
    countryCodeList['AO'] = '244';
    countryCodeList['AI'] = '1';
    countryCodeList['AQ'] = '672';
    countryCodeList['AG'] = '1';
    countryCodeList['AR'] = '54';
    countryCodeList['AM'] = '374';
    countryCodeList['AW'] = '297';
    countryCodeList['AU'] = '61';
    countryCodeList['AT'] = '43';
    countryCodeList['AZ'] = '994';
    countryCodeList['BS'] = '1';
    countryCodeList['BH'] = '973';
    countryCodeList['BD'] = '880';
    countryCodeList['BB'] = '1';
    countryCodeList['BY'] = '375';
    countryCodeList['BE'] = '32';
    countryCodeList['BZ'] = '501';
    countryCodeList['BJ'] = '229';
    countryCodeList['BM'] = '1';
    countryCodeList['BT'] = '975';
    countryCodeList['BO'] = '591';
    countryCodeList['BA'] = '387';
    countryCodeList['BW'] = '267';
    countryCodeList['BV'] = '47';
    countryCodeList['BR'] = '55';
    countryCodeList['IO'] = '246';
    countryCodeList['BN'] = '673';
    countryCodeList['BG'] = '359';
    countryCodeList['BF'] = '226';
    countryCodeList['BI'] = '257';
    countryCodeList['KH'] = '855';
    countryCodeList['CM'] = '237';
    countryCodeList['CA'] = '1';
    countryCodeList[''] = '238';
    countryCodeList['KY'] = '1';
    countryCodeList['CF'] = '236';
    countryCodeList['TD'] = '235';
    countryCodeList['CL'] = '56';
    countryCodeList['CN'] = '86';
    countryCodeList['CX'] = '';
    countryCodeList['CC'] = '';
    countryCodeList['CO'] = '57';
    countryCodeList['KM'] = '269';
    countryCodeList['CG'] = '242';
    countryCodeList['CD'] = '243';
    countryCodeList['CK'] = '682';
    countryCodeList['CR'] = '506';
    countryCodeList['CI'] = '225';
    countryCodeList['HR'] = '385';
    countryCodeList['CU'] = '53';
    countryCodeList['CY'] = '357';
    countryCodeList['CZ'] = '420';
    countryCodeList['DK'] = '45';
    countryCodeList['DJ'] = '253';
    countryCodeList['DM'] = '1';
    countryCodeList['DO'] = '1';
    countryCodeList['EC'] = '593';
    countryCodeList['EG'] = '20';
    countryCodeList['SV'] = '503';
    countryCodeList['GQ'] = '240';
    countryCodeList['ER'] = '291';
    countryCodeList['EE'] = '201';
    countryCodeList['ET'] = '251';
    countryCodeList['FK'] = '500';
    countryCodeList['FO'] = '298';
    countryCodeList['FJ'] = '679';
    countryCodeList['FI'] = '358';
    countryCodeList['FR'] = '33';
    countryCodeList['FX'] = '33';
    countryCodeList['GF'] = '594';
    countryCodeList['PF'] = '689';
    countryCodeList['TF'] = '33';
    countryCodeList['GA'] = '241';
    countryCodeList['GM'] = '220';
    countryCodeList['GE'] = '995';
    countryCodeList['DE'] = '49';
    countryCodeList['GG'] = '44';
    countryCodeList['GH'] = '233';
    countryCodeList['GI'] = '350';
    countryCodeList['GR'] = '30';
    countryCodeList['GL'] = '299';
    countryCodeList['GD'] = '1';
    countryCodeList['GP'] = '590';
    countryCodeList['GU'] = '1';
    countryCodeList['GT'] = '502';
    countryCodeList['GN'] = '224';
    countryCodeList['GW'] = '245';
    countryCodeList['GY'] = '592';
    countryCodeList['HT'] = '509';
    countryCodeList['HM'] = '1';
    countryCodeList['HN'] = '504';
    countryCodeList['HK'] = '852';
    countryCodeList['HU'] = '36';
    countryCodeList['IS'] = '354';
    countryCodeList['IN'] = '91';
    countryCodeList['ID'] = '62';
    countryCodeList['IR'] = '98';
    countryCodeList['IQ'] = '964';
    countryCodeList['IE'] = '353';
    countryCodeList['IL'] = '972';
    countryCodeList['IT'] = '39';
    countryCodeList['JM'] = '1';
    countryCodeList['JP'] = '81';
    countryCodeList['JO'] = '962';
    countryCodeList['KZ'] = '7';
    countryCodeList['KE'] = '254';
    countryCodeList['KI'] = '686';
    countryCodeList['KR'] = '82';
    countryCodeList['KP'] = '850';
    countryCodeList['KW'] = '965';
    countryCodeList['KG'] = '996';
    countryCodeList['LA'] = '856';
    countryCodeList['LV'] = '371';
    countryCodeList['LB'] = '961';
    countryCodeList['LS'] = '266';
    countryCodeList['LR'] = '231';
    countryCodeList['LY'] = '218';
    countryCodeList['LI'] = '423';
    countryCodeList['LT'] = '370';
    countryCodeList['LU'] = '352';
    countryCodeList['MO'] = '853';
    countryCodeList['MK'] = '389';
    countryCodeList['MG'] = '261';
    countryCodeList['MW'] = '265';
    countryCodeList['MY'] = '60';
    countryCodeList['MV'] = '960';
    countryCodeList['ML'] = '223';
    countryCodeList['MT'] = '356';
    countryCodeList['MH'] = '692';
    countryCodeList['MQ'] = '596';
    countryCodeList['MR'] = '222';
    countryCodeList['MU'] = '230';
    countryCodeList['YT'] = '269';
    countryCodeList['MX'] = '52';
    countryCodeList['FM'] = '691';
    countryCodeList['MD'] = '373';
    countryCodeList['MC'] = '377';
    countryCodeList['MN'] = '976';
    countryCodeList['ME'] = '382';
    countryCodeList['MS'] = '1';
    countryCodeList['MA'] = '212';
    countryCodeList['MZ'] = '258';
    countryCodeList['MM'] = '95';
    countryCodeList['NA'] = '264';
    countryCodeList['NR'] = '674';
    countryCodeList['NP'] = '977';
    countryCodeList['NL'] = '31';
    countryCodeList['AN'] = '599';
    countryCodeList['NC'] = '687';
    countryCodeList['NZ'] = '64';
    countryCodeList['NI'] = '505';
    countryCodeList['NE'] = '227';
    countryCodeList['NG'] = '234';
    countryCodeList['NU'] = '683';
    countryCodeList['NF'] = '6723';
    countryCodeList['MP'] = '1';
    countryCodeList['NO'] = '47';
    countryCodeList['OM'] = '968';
    countryCodeList['PK'] = '92';
    countryCodeList['PW'] = '680';
    countryCodeList['PS'] = '970';
    countryCodeList['PA'] = '507';
    countryCodeList['PG'] = '675';
    countryCodeList['PY'] = '595';
    countryCodeList['PE'] = '51';
    countryCodeList['PH'] = '63';
    countryCodeList['PN'] = '870';
    countryCodeList['PL'] = '48';
    countryCodeList['PT'] = '351';
    countryCodeList['PR'] = '1';
    countryCodeList['QA'] = '974';
    countryCodeList['RE'] = '262';
    countryCodeList['RO'] = '40';
    countryCodeList['RU'] = '7';
    countryCodeList['RW'] = '250';
    countryCodeList['SH'] = '290';
    countryCodeList['KN'] = '1';
    countryCodeList['LC'] = '1';
    countryCodeList['PM'] = '508';
    countryCodeList['VC'] = '1';
    countryCodeList['WS'] = '685';
    countryCodeList['SM'] = '378';
    countryCodeList['ST'] = '239';
    countryCodeList['SA'] = '966';
    countryCodeList['SN'] = '221';
    countryCodeList['RS'] = '381';
    countryCodeList['SC'] = '248';
    countryCodeList['SL'] = '232';
    countryCodeList['SG'] = '65';
    countryCodeList['SK'] = '421';
    countryCodeList['SI'] = '386';
    countryCodeList['SB'] = '677';
    countryCodeList['SO'] = '252';
    countryCodeList['ZA'] = '27';
    countryCodeList['GS'] = '44';
    countryCodeList['ES'] = '34';
    countryCodeList['LK'] = '94';
    countryCodeList['SD'] = '249';
    countryCodeList['SR'] = '597';
    countryCodeList['SJ'] = '79';
    countryCodeList['SZ'] = '268';
    countryCodeList['SE'] = '46';
    countryCodeList['CH'] = '41';
    countryCodeList['SY'] = '963';
    countryCodeList['TW'] = '886';
    countryCodeList['TJ'] = '992';
    countryCodeList['TZ'] = '255';
    countryCodeList['TH'] = '66';
    countryCodeList['TL'] = '670';
    countryCodeList['TG'] = '228';
    countryCodeList['TK'] = '690';
    countryCodeList['TO'] = '676';
    countryCodeList['TT'] = '1';
    countryCodeList['TN'] = '216';
    countryCodeList['TR'] = '90';
    countryCodeList['TM'] = '993';
    countryCodeList['TC'] = '1';
    countryCodeList['TV'] = '688';
    countryCodeList['UG'] = '256';
    countryCodeList['UA'] = '380';
    countryCodeList['AE'] = '971';
    countryCodeList['GB'] = '44';
    countryCodeList['US'] = '1';
    countryCodeList['UM'] = '1';
    countryCodeList['UY'] = '598';
    countryCodeList['UZ'] = '998';
    countryCodeList['VU'] = '678';
    countryCodeList['VA'] = '39';
    countryCodeList['VE'] = '58';
    countryCodeList['VN'] = '84';
    countryCodeList['VG'] = '1284';
    countryCodeList['VI'] = '1340';
    countryCodeList['WF'] = '681';
    countryCodeList['EH'] = '212';
    countryCodeList['YE'] = '967';
    countryCodeList['ZM'] = '260';
    countryCodeList['ZW'] = '263';
    function change_country(countrycode)
    {
        if (countrycode !== "")
        {
            countrycode = countrycode.toUpperCase();
            var country = countryCodeList[countrycode];
            document.getElementById("msg").innerHTML = country;
        }
        else
        {
            return false;
        }
    }
</script>

<!-- Code for display the Country and its Phone code -->
<span style="background-color:#F4FA58;color:#0101DF;">
    <b>
        Country Name:
    </b>
</span>
<select name=country id=country onchange='change_country(this.value);'>"; ?>
    <option value="select" selected>select</option>
     <?php
        foreach ($countries as $code => $name) {
            echo "<option value=\"$code\">$name</option>\n";
        }
      ?>
</select>

</br></br></br>

<div style="font-family:verdana;padding:20px 250px 0px 20px;border-radius:10px;border:10px solid #EE872A;">
    and also it's  phone code
    <span style="background-color:#F4FA58;color:#0101DF;">
        <b>+
            <label name="msg" id="msg"></label>
        </b>
    </span>
</div>


OUTPUT
~~~~~~~



No comments:

Post a Comment

Backup files to google drive using PHP coding

 Dear All, To backup files to Google Drive using PHP coding, you can use the Google Drive API and the Google Client Library for PHP. Here...