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
~~~~~~~



Display the differnet types of Diamond Shape Asterisk using Java

Hi All,

I write a program to display the Diamond Shape Asterisk using Java.


import java.util.Scanner;


//main class

public class diamond {
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int no = input.nextInt();
        diamond access = new diamond();
        System.out.println("The shape for this is: ");
        access.diamond_res(no);
       
    }

 public String diamond_star(int no) //method1
    {
        if(no>0)
        {
            return "* " + diamond_star(no-1);
        }
        else
        {
            return " ";
        }
    }
     public String diamond_star1(int no)//method2
    {
        if(no>0)
        {
            return " * " + diamond_star(no-1);//access method1
        }
        else
        {
            return " ";
        }
    }
    public String blankSpace(int no) //method3
    {
        if(no>0)
        {
            return " " + blankSpace(no-1);
        }
        else
        {
            return " ";
        }
    }
    public void diamond_res(int no)//method4
    {
      System.out.print(" Output 1.\n\n");
          /* for output 1*/
        for(int i=1; i<no/2; i++)
        {
            System.out.print(blankSpace(no-i));//access method3
             System.out.println(diamond_star(i));//access method1
           
        }
         for(int i=0; i<no/2; i++)
        {
            System.out.println(diamond_star1(no-i));//access method2
            System.out.print(blankSpace(i));//access method3
        }
          System.out.print(" Output 2.\n\n");
          /* for output 2*/
        for(int i=1; i<no; i++)
        {
            System.out.print(blankSpace(no-i));//access method3
             System.out.println(diamond_star(i));//access method1
           
        }
         for(int i=0; i<no/2; i++)
        {
            System.out.println(diamond_star1(no-i));//access method2
            System.out.print(blankSpace(i));//access method3
        }
       System.out.print(" Output 3 .\n\n");
          /* for output 3*/
        for(int i=1; i<no/5; i++)
        {
            System.out.print(blankSpace(no-i));//access method3
             System.out.println(diamond_star(i));//access method1
           
        }
         for(int i=0; i<no; i++)
        {
            System.out.println(diamond_star1(no-i));//access method2
            System.out.print(blankSpace(i));//access method3
        }
    System.out.print(" Output 4 .\n\n");
          /* for output 4 */
        for(int i=1; i<no; i++)
        {
            System.out.print(blankSpace(no-i));//access method3
             System.out.println(diamond_star(i));//access method1
           
        }
         for(int i=0; i<no/5; i++)
        {
            System.out.println(diamond_star1(no-i));//access method2
            System.out.print(blankSpace(i));//access method3
        }
        System.out.print(" Output 5 .\n\n");
        /* for output 5 */
        for(int i=1; i<no/5; i++)
        {
            System.out.print(blankSpace(no-i));
             System.out.println(diamond_star(i));
           
        }
         for(int i=0; i<no/3; i++)
        {
            System.out.println(diamond_star1(no-i));
            System.out.print(blankSpace(i));
        }
          System.out.print(" Output 6 .\n\n");
        /* for output 6 */
        for(int i=1; i<no*2; i++)
        {
            System.out.print(blankSpace(no-i));
             System.out.println(diamond_star(i));
           
        }
         for(int i=0; i<no*2; i++)
        {
            System.out.println(diamond_star1(no-i));
            System.out.print(blankSpace(i));
        }
     
     
    }
   
}

OUTPUT

~~~~~~~~

Enter a number: 10
The shape for this is: 
 Output 1.

          *  
         * *  
        * * *  
       * * * *  
 * * * * * * * * * *  
  * * * * * * * * *  
   * * * * * * * *  
    * * * * * * *  
     * * * * * *  
      Output 2.

          *  
         * *  
        * * *  
       * * * *  
      * * * * *  
     * * * * * *  
    * * * * * * *  
   * * * * * * * *  
  * * * * * * * * *  
 * * * * * * * * * *  
  * * * * * * * * *  
   * * * * * * * *  
    * * * * * * *  
     * * * * * *  
      Output 3 .

          *  
 * * * * * * * * * *  
  * * * * * * * * *  
   * * * * * * * *  
    * * * * * * *  
     * * * * * *  
      * * * * *  
       * * * *  
        * * *  
         * *  
          *  
           Output 4 .

          *  
         * *  
        * * *  
       * * * *  
      * * * * *  
     * * * * * *  
    * * * * * * *  
   * * * * * * * *  
  * * * * * * * * *  
 * * * * * * * * * *  
  * * * * * * * * *  
   Output 5 .

          *  
 * * * * * * * * * *  
  * * * * * * * * *  
   * * * * * * * *  
    Output 6 .

          *  
         * *  
        * * *  
       * * * *  
      * * * * *  
     * * * * * *  
    * * * * * * *  
   * * * * * * * *  
  * * * * * * * * *  
 * * * * * * * * * *  
 * * * * * * * * * * *  
 * * * * * * * * * * * *  
 * * * * * * * * * * * * *  
 * * * * * * * * * * * * * *  
 * * * * * * * * * * * * * * *  
 * * * * * * * * * * * * * * * *  
 * * * * * * * * * * * * * * * * *  
 * * * * * * * * * * * * * * * * * *  
 * * * * * * * * * * * * * * * * * * *  
 * * * * * * * * * *  
  * * * * * * * * *  
   * * * * * * * *  
    * * * * * * *  
     * * * * * *  
      * * * * *  
       * * * *  
        * * *  
         * *  
          *  
           

Display the Diamond Shape Asterisk using Java

Hi All,

I write a program to display the Diamond Shape Asterisk using Java.

import java.util.Scanner;


//main class

public class diamond {
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int no = input.nextInt();
        diamond access = new diamond();
        System.out.println("The shape for this is: ");
        access.diamond_res(no);
        
    }

 public String diamond_star(int no) //method1
    {
        if(no>0)
        {
            return "* " + diamond_star(no-1);
        }
        else
        {
            return " ";
        }
    }
     public String diamond_star1(int no)//method2
    {
        if(no>0)
        {
            return " * " + diamond_star(no-1);//access method1
        }
        else
        {
            return " ";
        }
    }
    public String blankSpace(int no) //method3
    {
        if(no>0)
        {
            return " " + blankSpace(no-1);
        }
        else
        {
            return " ";
        }
    }
    public void diamond_res(int no)//method4
    {
        for(int i=1; i<no; i++)
        {
            System.out.print(blankSpace(no-i));//access method3
             System.out.println(diamond_star(i));//access method1
            
        }
         for(int i=0; i<no; i++)
        {
            System.out.println(diamond_star1(no-i));//access method2
            System.out.print(blankSpace(i));//access method3
        }
     
    }
    
}

OUTPUT

~~~~~~~~

Enter a number: 6
The shape for this is:
      * 
     * * 
    * * * 
   * * * * 
  * * * * * 
 * * * * * * 
  * * * * * 
   * * * * 
    * * * 
     * * 
      * 

Friday, June 7

Exchange Sort using Java

Hi All,

Here I write a program for Exchange Sort Using Java.

The exchange sort compares each element of an array and swap those elements that are not in their proper position, just like a bubble sort does. The only difference between the two sorting algorithms is the manner in which they compare the elements. 


public class exchangeSort {

    public static void main(String args[]) {
        int n, i, j, temp;
        Scanner in = new Scanner(System.in);
        System.out.print("Please Enter how many numbers to be sorted : \t");
        n = in.nextInt();
        System.out.println("Enter the numbers\n");
        int num[] = new int[n];
        for (i = 0; i < n; i++) {
            num[i] = in.nextInt();
        }
       
        for (i = 0; i < num.length - 1; i++) {
            for (j = i + 1; j < num.length; j++) {
                if (num[ i] > num[ j]) //sorting into Ascending order  /* if you want descending order (num[ i] < num[ j]) */
                {
                    temp = num[ i];   //swapping
                    num[ i] = num[ j];
                    num[ j] = temp;
                }
            }
        }
        try {
            for (int k = 0; k < num.length; k++) {
                System.out.print(num[k] + "|");
            }
            System.out.println();
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("Exception");
        }
    }
}


OUTPUT

~~~~~~~

Please Enter how many numbers to be sorted :     8

Enter the numbers

50
62
1
9
2
100
60
55

Sorted Elements are :
1  2  9  50  55  60  62  100

Merging two array values using Java

Hi All,

Here  I write a program for Merge two array values using java.


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class mergeArray {
   public static void main(String args[]) {
      String x[] = { "S", "K", "i" };
      String y[] = { "T", "E","C","H" };
      List list = new ArrayList(Arrays.asList(x));
      list.addAll(Arrays.asList(y));
      Object[] z = list.toArray();
      System.out.println("Merge two array result \n "+Arrays.toString(z));
   }
}
 
 

Output

~~~~~~ 

Merge two array result 
[S, K, i, T, E, C, H]

Thursday, June 6

Merge Sort using Java

Hi All,

Here I write a program for Merge Sort using java

Merge sort or merge sort is a simple but efficient sort algorithm that splits the list into two sub lists, sorts each one, then combines them into a single sorted list. It has good worst-case performance and requires only sequential access, making it ideal for sequential data structures like linked lists.




package Sorting;

import java.util.Scanner;

/* sort method */
public class MergeSort1 {

    static void MergeMethod(int a[], int b) {
        int sub[] = new int[25];
        int i, j, k, lev1, lev2, lev3, u2, size;
        size = 1;
        while (size < b) { // check the array size
            lev1 = 0;
            k = 0;
            while ((lev1 + size) < b) {
                lev2 = lev1 + size;
                lev3 = lev2 - 1;
                u2 = ((lev2 + size - 1) < b) ? (lev2 + size - 1) : (b - 1);
                for (i = lev1, j = lev2; i <= lev3 && j <= u2; k++) {
                    if (a[i] <= a[j]) {
                        sub[k] = a[i++];
                    } else {
                        sub[k] = a[j++];
                    }
                }
                for (; i <= lev3; k++) {
                    sub[k] = a[i++];
                }

                for (; j <= u2; k++) {
                    sub[k] = a[j++];
                }
                lev1 = u2 + 1;
            }
            for (i = lev1; k < b; i++) {
                sub[k++] = a[i];
            }
            for (i = 0; i < b; i++) {
                a[i] = sub[i];
            }
            size *= 2;
        }
    }

    public static void main(String args[]) {
        int i, n;
       /* Getting value  from user */
        Scanner in = new Scanner(System.in);
        System.out.print("Please Enter how many numbers to be sorted : \t");
        n=new Scanner(System.in).nextInt();  
        System.out.println("\nEnter the numbers\n");
        int x[] = new int[n];
        for (i = 0; i < n; i++) {
            x[i] = in.nextInt();
        }
        MergeMethod(x, n);

        /* print out put of array*/
        System.out.println("\nSorted Elements are :");
        for (i = 0; i < n; i++) {
            System.out.print(x[i] + "  ");
        }
    }
}


OUTPUT:

~~~~~~~~

Please Enter how many numbers to be sorted :     8

Enter the numbers

5
60
2
1
95
25
35
3

Sorted Elements are :
1  2  3  5  25  35  60  95 

Removing duplicate values from the array list using java -- it contains String compression,List,Hashset techniques

Hi All,


Here I Write a program for Removing duplicate values from the array list using three techniques
1. Normal String compression for finding duplicates from array list 

2. List using to compare string and find & remove duplicates from array list 

3. Hash set method to find and remove the duplicates from the array list.


import java.util.Set;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;

public class removeDuplicateas {

    public static void main(String args[]) {
        String[] value = new String[]{"S", "K", "I", "T", "E", "C", "H", "", "-", "a", "b", "a", "b"};

        /* Normal  string method for find and display the duplicates from array*/
        if (checkDuplicated_withNormal(value)) {
            System.out.println("Array contains duplicate values \n");
        }
         /* Hashset method for find and remove the duplicates from array*/
        if (checkDuplicated_withSet(value)) {
            System.out.println(" \n");
        }

        /* List method using find and remove the duplicates from array*/

        listCheck();

    }

    public static void listCheck() {

        List<String> skilist = (List<String>) Arrays.asList("macos", "windows", "linux", "Android", "", "Boss", "macos", "windows");

        LinkedHashSet<String> lsToset = new LinkedHashSet<String>(skilist);
        List<String> lsWoDuplicates = new ArrayList<String>(lsToset);
        System.out.println("ArrayList size without duplicate: " + lsToset.size());
        System.out.println("ArrayList after removing duplicates in order: " + lsWoDuplicates);
    }

    //check duplicated value using noraml string check method
    private static boolean checkDuplicated_withNormal(String[] value) {
        for (int i = 0; i < value.length; i++) {
            String ValueCheck = value[i];
            if (ValueCheck == null || ValueCheck.equals("")) {
                continue; //empty value ignore condition
            }
            for (int j = 0; j < value.length; j++) {
                if (i == j) {
                    continue;
                }
                String Valuematch = value[j];
                if (ValueCheck.equals(Valuematch)) {
                    return true;
                }
            }

        }
        return false;

    }

    //check Without Duplicate values
    private static boolean checkDuplicated_withSet(String[] values) {
        Set<String> sValueSet = new HashSet<String>();
        for (String temp : values) {
            if (sValueSet.contains(temp)) {
                return true;
            } else if (!temp.equals("")) {
                sValueSet.add(temp);
            }
            System.out.println("Without Duplicate values " + sValueSet.toString());
        }
        return false;
    }
}


output:

~~~~~~~


Array contains duplicate values

Without Duplicate values [S]
Without Duplicate values [S, K]
Without Duplicate values [S, I, K]
Without Duplicate values [T, S, I, K]
Without Duplicate values [E, T, S, I, K]
Without Duplicate values [E, T, S, C, I, K]
Without Duplicate values [E, T, S, C, H, I, K]
Without Duplicate values [E, T, S, C, H, I, K]
Without Duplicate values [E, T, S, C, H, I, -, K]
Without Duplicate values [E, T, S, a, C, H, I, -, K]
Without Duplicate values [E, T, b, S, a, C, H, I, -, K]


ArrayList size without duplicate: 6
ArrayList after removing duplicates in order: [macos, windows, linux, Android, , Boss]

Using multiple Jquery Datepicker and generates a dynamic table and export Word file option in PHP

Hi All,

 

Here I used Multiple JQuery date picker in a page with Start and End date validation and also generate a dynamic table for the given date limit. Also available in export Word file option.



<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.16.custom.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
/*  Style added for table layout*/
 <STYLE type="text/css"> 
.tabDesign {
    margin:0px;padding:0px;
    width:70%;   
   
   
    -moz-border-radius-bottomleft:0px;
    -webkit-border-bottom-left-radius:0px;
    border-bottom-left-radius:0px;
   
    -moz-border-radius-bottomright:0px;
    -webkit-border-bottom-right-radius:0px;
    border-bottom-right-radius:0px;
   
    -moz-border-radius-topright:0px;
    -webkit-border-top-right-radius:0px;
    border-top-right-radius:0px;
   
    -moz-border-radius-topleft:0px;
    -webkit-border-top-left-radius:0px;
    border-top-left-radius:0px;
}.tabDesign table{
    width:70%;   
    margin:0px;padding:0px;
}.tabDesign tr:last-child td:last-child {
    -moz-border-radius-bottomright:0px;
    -webkit-border-bottom-right-radius:0px;
    border-bottom-right-radius:0px;
}
.tabDesign table tr:first-child td:first-child {
    -moz-border-radius-topleft:0px;
    -webkit-border-top-left-radius:0px;
    border-top-left-radius:0px;
}
.tabDesign table tr:first-child td:last-child {
    -moz-border-radius-topright:0px;
    -webkit-border-top-right-radius:0px;
    border-top-right-radius:0px;
}.tabDesign tr:last-child td:first-child{
    -moz-border-radius-bottomleft:0px;
    -webkit-border-bottom-left-radius:0px;
    border-bottom-left-radius:0px;
}.tabDesign tr:hover td{
   
}
.tabDesign tr:nth-child(odd){ background-color:#e5e5e5; }
.tabDesign tr:nth-child(even)    { background-color:#ffffff; }.tabDesign td{
    vertical-align:middle;
   
   
    border:1px solid #000000;
    border-width:0px 1px 1px 0px;
    text-align:left;
    padding:7px;
    font-size:12px;
    font-family:Arial;
    font-weight:normal;
    color:#000000;
}.tabDesign tr:last-child td{
    border-width:0px 1px 0px 0px;
}.tabDesign tr td:last-child{
    border-width:0px 0px 1px 0px;
}.tabDesign tr:last-child td:last-child{
    border-width:0px 0px 0px 0px;
}
.tabDesign tr:first-child td{
        background:-o-linear-gradient(bottom, #cccccc 5%, #b2b2b2 100%);    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #cccccc), color-stop(1, #b2b2b2) );
    background:-moz-linear-gradient( center top, #cccccc 5%, #b2b2b2 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#cccccc", endColorstr="#b2b2b2");    background: -o-linear-gradient(top,#cccccc,b2b2b2);

    background-color:#cccccc;
    border:0px solid #000000;
    text-align:center;
    border-width:0px 0px 1px 1px;
    font-size:14px;
    font-family:Arial;
    font-weight:bold;
    color:#000000;
}
.tabDesign tr:first-child:hover td{
    background:-o-linear-gradient(bottom, #cccccc 5%, #b2b2b2 100%);    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #cccccc), color-stop(1, #b2b2b2) );
    background:-moz-linear-gradient( center top, #cccccc 5%, #b2b2b2 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#cccccc", endColorstr="#b2b2b2");    background: -o-linear-gradient(top,#cccccc,b2b2b2);

    background-color:#cccccc;
}
.tabDesign tr:first-child td:first-child{
    border-width:0px 0px 1px 0px;
}
.tabDesign tr:first-child td:last-child{
    border-width:0px 0px 1px 1px;
}

</style>

/* Start and end date validation for jquery date picker*/

<script type="text/javascript">
    $(document).ready(function() {
        $('#table').hide();
        $('#submit').click(function() {
            if ($('#start_date').val() == "") {
                alert("Please Select Start Date");
                $('#table').hide();
            }
            else if ($('#end_date').val() == "") {
                alert("Please Select End Date");
                $('#table').hide();
            }
        });
        $(document).ready(function() {
            $("#start_date").datepicker({
                showOn: "button",
                buttonImage: "images/calendar.gif",
                buttonImageOnly: true,
                numberOfMonths: 1,
                onSelect: function(selected) {
                    $("#end_date").datepicker("option", "minDate", selected)
                    var dateString = $("#start_date").val();
                    var date = new Date(dateString);

                }
            });
            $("#end_date").datepicker({
                showOn: "button",
                buttonImage: "images/calendar.gif",
                buttonImageOnly: true,
                numberOfMonths: 1,
                onSelect: function(selected) {
                    $("#start_date").datepicker("option", "maxDate", selected)
                    var dateString = $("#end_date").val();
                    var date = new Date(dateString);
                }
            });
        });
    });
</script>
<script type="text/javascript">
    function clearPage() {
        $('#clear').click(function() {
            $('#table').hide();
            $('#start_date').val() === "";
            $('#start_date').val() === "";

        });
    }
    function datelimit() {
        var st_date = document.getElementById('start_date').value;
        var ed_date = document.getElementById('end_date').value;
        showUser(st_date, ed_date);
    }

/* Ajax for dynamic table creation based on date limits*/

    function showUser(Stdate, enddate)
    {
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function()
        {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "AttendanceSheet_1.php?st=" + Stdate + '&ed=' + enddate + '&submit=yes', true);
        xmlhttp.send();
    }
</script>

/*  Form  started */
<?php
    $sub = $_REQUEST['submit'];
    if (strcmp($sub, "yes") != 0) { ?>
        <div id="main_table">
            <b>Attendance Sheet</b>
        </div>
        <div id="date">
            <b>Start Date</b>
                <input name="start_date" id="start_date" readonly="readonly" >
            <b>End Date</b>
                <input name="end_date" id="end_date" readonly="readonly">
        </div>
        <div id="finish">
            <input type="submit" id="submit" name="submit" value="Submit" onclick="datelimit()">
            <input type="submit" id="clear" name="clear" value="Clear" onclick="clearPage()" >
        </div>
    <?php } ?>

/*  Dynamic table generation code */

    <div id="txtHint">
        <b>
            <?php
                $st_date = $_REQUEST['st'];
                $st_date1 = changeToDateFormat($st_date);
                $ed_date = $_REQUEST['ed'];
                $ed_date1 = changeToDateFormat($ed_date);
               
                function changeToDateFormat($cdate) {
                    list($mon, $dat, $year) = explode("/", $cdate);
                    return $year . "-" . $mon . "-" . $dat;
                }
            ?>
        </b>
    </div>
    <div id="table" class="tabDesign">
        <?php
            $hostname = "localhost";
            $dbname = "sears";
            $dbusername = "root";
            $dbpassword = "";
           
            $con = mysql_connect($hostname, $dbusername, $dbpassword);
            mysql_select_db($dbname, $con);
            $qry = "select ilt.ilt_id, ilt.courseid,course.title as title, course.start_date, course.end_date, course.cversion as version,
                    From_unixtime(iltsess.session_stime) as start_time,From_unixtime(iltsess.session_etime) as end_time,iltsess.instructor_id instructor_name
                    from lw_ilt ilt,lw_courses course,lw_ilt_session iltsess
                    where course.courseid=ilt.courseid and course.status='ACTIVE' and ilt.status='ACTIVE' and ilt.ilt_id=iltsess.ilt_id
                    and course.start_date between '$st_date1' and '$ed_date1' order by course.start_date";           
            $result = mysql_query($qry);
            if (!$result) {
                echo 'Could not run query: ' . mysql_error();
                exit;
            }
            echo "</br>";
                        $count = mysql_num_rows($result);
            echo "<table id='table' width='70%' align='centre' border='2px' colspan='2' style='border-collapse :collapse'>
                                <tr border='1px'>
                                <th>Coursename</th>
                                <th>Start Date</th>
                                <th>Status</th>
                                <th>Action</th>
                                </tr>";
                                if($count==0)
                                    echo "<tr><td colspan='4' style='text-align:center;'>No courses are available in these dates</td></tr></table>";
                                else{
                        while ($row = mysql_fetch_array($result)) {
                            $version = $row[5];
                            if ($version == '-5.00')
                                $versionval = 'Closed';
                            else if ($version == '0.00')
                                $versionval = 'Open';
                            echo "<tr>
                                    <td>" . $row[2] . "</td>
                                    <td>" . $row[3] . "</td>
                                    <td>" . $versionval . "</td>";
                                            $query = "select * from lw_ilt_attendance ilt_att, lw_users user ,lw_ilt ilt
                                                      where user.userid=ilt_att.user_id and ilt_att.ilt_id=ilt.ilt_id and ilt.ilt_id=" . $row[0];
                                            $res = mysql_query($query);
                                            if (!$res) {
                                                echo 'Could not run query: ' . mysql_error();
                                                exit;
                                            }
                                            $doc = mysql_num_rows($res);
                                            if ($doc == 0)
                                                echo "<td style='background-color:#DDD9C3;color:black;'>No One Registered this course</td></tr>";
                                            else
                                                echo "<td><a href='report.php?id=$row[0]'>Export as Document</a></td>
                                </tr>";
                        }
            echo "</table>";
                         }
        mysql_close($con);
    ?>
</div>


output:

~~~~~~~


Showing records between dates

























NO Record found this days





Friday, May 17

Sending EMail with attachment (Excel sheet) using PHP

Hi All, 


Here I write a program for Email with an attached excel document using PHP. Also I design dynamic table for maintaining count of course completed user.


<?php

$hostname="localhost"; // Enter your System address
$dbname="sample";    // Database name
$dbusername="root"; // Enter username of database
$dbpassword="";        // Enter if you have password of your MySql db
$DOWNLOADPATH='C:/Documents and Settings/Skitech/Desktop'; // File Downloadable location

error_reporting(E_ALL);

$date=date('dS M Y'); // date format
$date1=date('d_M_Y'); // filename date format

$today=date('l');
//if($today=='Friday'){
   
    $ActiveUser=0;
    $CompletedUser=0;
    $NAcount=0;
    $NotAttempted=0;
    $InprogressUser=0;
    $font_type='calibri';
    $font_size='16px';
       
        $styleArray = array(
            'font' => array(
            'bold' => true,
            )
        );

    $my_subject="Test Report as on ".$date;
       
    $my_message="<span style='font-family:".$font_type."; font-size:".$font_size.";'><br>
        Hi All,<br><br>  
    Please enter the text you want to display in body of message.

    <br><br>

    </span>
    <table style='font-family:".$font_type."; font-size:".$font_size."; border: 1px solid #000000; border-collapse:collapse;' width='400' border='1'>
      <tr height='30' bgcolor='#BFBEBE'>
        <td width='400'><b>&nbsp;User Type</b></td>
        <td width='100'><b>&nbsp;Count</b></td>
      </tr>";
   
    //Database connection
    $con = mysql_connect($hostname,$dbusername,$dbpassword);
    mysql_select_db($dbname, $con);
   
    //Getting count of completed status count
    $qry1 ="select course.title AS coursename,course.username AS username    from test_course course;";
    $result1= mysql_query($qry1);
    $data=  mysql_fetch_array($result1);
    $ActiveUser=mysql_num_rows($result1);
   
    //Getting count of incompleted status count
    $qry2 = "select distinct ss.userid,ss.username from test_course_history ss;";
    $result2= mysql_query($qry2);
    $CompletedUser=mysql_num_rows($result2);
   
    //Getting count of Not attempted status count
    $qry3 = "select distinct ss.userid,user.username from test_course_history ss, test_users user
            where user.userid=ss.userid and user.`status`='Active'";
    $result3= mysql_query($qry3);
    $NAcount=mysql_num_rows($result3);
    $InprogressUser=$NAcount-$CompletedUser;
   
    $NotAttempted=$ActiveUser-($CompletedUser+$InprogressUser);   

    $my_message.="
        <tr bgcolor='#FFFFFF'>
            <td height='30' width='400'>&nbsp;Users - Completed the course</td>
            <td height='30' width='100'>&nbsp;".$CompletedUser."</td>
        </tr>
        <tr bgcolor='#FFFFFF'>
            <td height='30' width='400'>&nbsp;Users - Learning In Progress</td>
            <td height='30' width='100'>&nbsp;".$InprogressUser."</td>
        </tr>
        <tr bgcolor='#FFFFFF'>
            <td height='30' width='400'>&nbsp;Users - Not Attempted</td>
            <td height='30' width='100'>&nbsp;".$NotAttempted."</td>
        </tr>
        <tr bgcolor='#FFFF00'>
            <td height='30' width='400'>&nbsp;Total Active Users</td>
            <td height='30' width='100'>&nbsp;".$ActiveUser."</td>
        </tr>
    </table><br><br><span style='font-family:".$font_type."; font-size:".$font_size.";'>
    Thanks,<br>
    Regards,<br>
    Balamurugan M.R<br>
    SkiTech Ltd<br>
    <br>
    </span>";
    echo $my_message;

    $query="Select * from test_courses";
    $result=mysql_query($query);
   
    $filename='test_Report_as_on_'.$date1.'.xls';
       
    $file_headerdata= 'Username' . "\t" . 'Coursename' . "\t" . 'Completion Status' ."\t" . 'Total Attempts'."\n";
        $file_headerdata = getStyle($file_headerdata)->applyFromArray($styleArray);
    while($row=mysql_fetch_array($result))
    {
        if($row[1]=='Test Online Module')
            $row[1]='Test Online Course';
        if($row[3]==0 && $row[2]!='completed')
            $row[2]='Not Attempted';
        else if($row[3]!=0 && $row[2]!='completed')
            $row[2]='Incomplete';
       
        $file_data[] =$row[0]."\t".$row[1]."\t".$row[2]."\t".$row[3]. "\n";
    }
    mysql_close($con);
        $fname= writetofile($filename,$file_data,$file_headerdata);
   

    // Send mail functionality   
    $my_name = "SKiTECH SUPPORT";
    $my_mail = "Skitech.slm@gmail.com";
    $my_replyto = "skitech.support@gmail.com";
    $to = "skitech.slm@gmail.com";   
    $cc="krish.mr@gamil.com";       
    send_mail($to, $my_mail, $my_name, $my_replyto, $my_subject, $my_message,$cc,$fname);
//}

//Write all data in Excel file and return the File name with its location 
function writetofile($filename,$file_data,$file_headerdata) {
   
    global $DOWNLOADPATH;
    $handle = fopen($DOWNLOADPATH.$filename, 'wb') or die("ERR:Can't open file");
    fwrite($handle, $file_headerdata);
    foreach($file_data as $key => $val){
        echo "\n";
        fwrite($handle, $val);
    }
    fclose($handle);
    $fname=$DOWNLOADPATH.$filename;
    return $fname;
}

//Send mail concept to send a mail with Attachment
function send_mail($mailto, $from_mail, $from_name, $replyto, $subject, $message,$cc,$fname) {
    //File  open method
    $fp = fopen($fname, "rb");
    $upload_size=filesize($fname);
    $file = fread($fp, $upload_size);

    $file = chunk_split(base64_encode($file));
    $num = md5(time());
    $upload_type=filetype($fname);
   
     //Normal headers

    $headers  = "From: ".$from_name." <".$from_mail.">\r\n";
    $headers .= "Reply-To: ".$replyto."\r\n";
    $headers .= "Cc: ".$cc."\r\n";
    $headers  .= "MIME-Version: 1.0\r\n";
    $headers  .= "Content-Type: multipart/mixed; ";
    $headers  .= "boundary=".$num."\r\n";
    $headers  .= "--$num\r\n";  

    // With message
   
    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Content-Transfer-Encoding: 8bit\r\n";
    $headers .= $message."\r\n\r\n";
    $headers .= "--".$num."\n";

    // Attachment headers

    $headers  .= "Content-Type:".$upload_type." ";
    $headers  .= "name=\"".$fname."\"r\n";
    $headers  .= "Content-Transfer-Encoding: base64\r\n";
    $headers  .= "Content-Disposition: attachment; ";
    $headers  .= "filename=\"".basename($fname)."\"\r\n\n";
    $headers  .= "".$file."\r\n";
    $headers  .= "--".$num."--";



    //Send mail method

    if (mail($mailto, $subject, "", $headers)) {
    echo "mail send ... OK"; // or use booleans here
    } else {
    echo "mail send ... ERROR!";
    }
}

?>


OUTPUT:
~~~~~~~~~~

Monday, May 13

Insert boot disk and press any key error solution

Hi All,

 "No bootable device – insert boot disk and press any key"  Solution


 
















If your computer won't boot,and you are seeing a no bootable device – insert boot disk and press any key notification, then you can follow the below guide to fix your computer.
Here are some other Windows 7 and Vista errors which this guide can fix:
  • no bootable device – insert boot disk and press any key
  • NTLDR is missing or corrupted
  • Ntoskrnl.exe is missing
  • Ntdetect.com is missing
  • BOOTMGR is missing or corrupted
  • NTFS.SYS is missing
  • Hal.dll is missing

How to fix a computer that won't boot - Instructions


------------------------------------------------------
Windows 7 only:
If you don't have a install DVD for Windows 7, you can download a legal copy from the below links:
Official Windows 7 SP1 ISO from Digital River with 30 days free trial

http://msft.digitalrivercontent.net/win/X17-24208.iso > Windows 7 Home Premium SP1 x86 English
http://msft.digitalrivercontent.net/win/X17-24209.iso > Windows 7 Home Premium SP1 x64 English

http://msft.digitalrivercontent.net/win/X17-24280.iso > Windows 7 Professional SP1 x86 English
http://msft.digitalrivercontent.net/win/X17-24281.iso > Windows 7 Professional SP1 x64 English

http://msft.digitalrivercontent.net/win/X17-24394.iso > Windows 7 Ultimate SP1 x86 English
http://msft.digitalrivercontent.net/win/X17-24395.iso > Windows 7 Ultimate SP1 x64 English
Make sure you get the same version you have installed: 32 or 64 bit; Home Premium, Pro or Ultimate.
------------------------------------------------------
  1. Insert the Windows 7 System Repair DVD or Installation DVD and reboot.
  2. Select the correct keyboard input method and click Next.
       
  3. Choose the Repair your computer option located in the lower left of the dispay.
       
  4. When the ‘System Recovery Options’ screen appears verify that the “Use recovery tools that can help fix problems starting Windows” is selected.
       
  5. Now from the menu list select the Command Prompt option.
           
  6. On the command prompt,please type the following commands.
    bootrec.exe /fixmbr
       
  7. Restart the computer.

If the above did not work, follow the instructions below and start a thread in the Troubleshooting Software/Hardware Issues forum.

Download Farbar Recovery Scan Tool from the below link:
  • For 32 bit systems download Farbar Recovery Scan Tool and save it to a flash drive.
    For 64 bit systems download Farbar Recovery Scan Tool x64 and save it to a flash drive.

  • Also download List Parts 32-bit or Listparts 64-bit and save it to the flash drive also.

  • Plug the flashdrive into the unbootable PC.

  • Enter System Recovery Options.

  • To enter System Recovery Options from the Advanced Boot Options:
    • Restart the computer.
    • As soon as the BIOS is loaded begin tapping the F8 key until Advanced Boot Options appears.
    • Use the arrow keys to select the Repair your computer menu item.
    • Select US as the keyboard language settings, and then click Next.
    • Select the operating system you want to repair, and then click Next.
    • Select your user account an click Next.
    To enter System Recovery Options by using Windows installation disc:
    • Insert the installation disc.
    • Restart your computer.
    • If prompted, press any key to start Windows from the installation disc. If your computer is not configured to start from a CD or DVD, check your BIOS settings.
    • Click Repair your computer.
    • Select US as the keyboard language settings, and then click Next.
    • Select the operating system you want to repair, and then click Next.
    • Select your user account and click Next.
  • On the System Recovery Options menu you will get the following options:
    Startup Repair
    
    System Restore
    
    Windows Complete PC Restore
    
    Windows Memory Diagnostic Tool
    
    Command Prompt
    1. Select Command Prompt
    2. In the command window type in notepad and press Enter.
    3. The notepad opens. Under File menu select Open.
    4. Select "Computer" and find your flash drive letter and close the notepad.
    5. In the command window type e:\frst.exe (for x64 bit version type e:\frst64) and press Enter
      Note: Replace letter e with the drive letter of your flash drive.
    6. The tool will start to run.
    7. When the tool opens click Yes to disclaimer.
    8. Press Scan button.
    9. FRST will let you know when the scan is complete and has written the FRST.txt to file, close the message.
    10. Back in the command prompt, type e:\listparts.exe (for x64 bit version type e:\listparts64.exe) and press Enter
    11. ListParts will start to run. Check the box beside List BCD and click Scan
    12. When finished scanning it will make a log Result.txt on the flash drive
    13. Type exit
    14. Please copy and paste both FRST.txt and Result.txt logs in your next reply

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...