Tuesday, June 25

Program for Arranging ascending order of names in the given Text file using java

Hi All,

Here I write a program for Arranging ascending order of names in the given file.

 1. Read names from the given file.  

2. Checking name contains initial then the initial to be replaces it and end of the name.

3. Very easy method to list names in ascending order within seconds.

4. Again, I write values of out put in separate file.


Note:
1. Each line contains a single name in the given file.
2. The empty line between the name a not allowed. It considers as an end of the file.  

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class attendaceOrder {

    public static void main(String[] args) throws IOException {
        BufferedReader br = null;
        ArrayList<String> unsortedList = new ArrayList<String>();   
        File file;
        /* File Read Method*/
        try {

            String name;

            br = new BufferedReader(new FileReader("C:\\Documents and Settings\\sify\\Desktop\\names.txt"));

            while ((name = br.readLine()) != null) {
                System.out.println("Users Listed in the sheet :\n" + name);
                /* Check the .(dot) pattern in given names*/
                String dot = ".";
                boolean res = name.contains(dot);
                if (res == true) {
                    int l = name.lastIndexOf(dot);
                    if (l == 1 || l == 3 || l == 5) {
                        String Lastname = name.substring(0, l);
                        int name1 = name.substring(l + 1).length();
                        String Firstname = name.substring(l + 1);
                        String str = Firstname.concat("." + Lastname);
                        unsortedList.add(str);

                    } else {
                        //
                    }
                } else {
                    unsortedList.add(name);
                }
            }
            /* Adding the values in ArrayList*/
            Collections.sort(unsortedList);
            System.out.println("Users Listed in the sheet - Ascending order :\n " + unsortedList);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (br != null) {
                    br.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        Arrays.sort(unsortedList.toString().toCharArray());

        /* File Write Method*/
        try {
            file = new File("C:\\Documents and Settings\\sify\\Desktop\\names1.txt");
            // if file doesnt exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            }
            for (String s : unsortedList) {
                System.out.println(s);
            }

            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            /* Write list of names in given file*/
            bw.write(unsortedList.toString());
            bw.close();

            System.out.println("Done :-)");

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

OUTPUT

~~~~~~~~~

Users Listed in the sheet :    Aswini
Users Listed in the sheet :    Asvini
Users Listed in the sheet :    Bharani
Users Listed in the sheet :    Parani
Users Listed in the sheet :    Krithika
Users Listed in the sheet :    Karthigai
Users Listed in the sheet :    Rohini R
Users Listed in the sheet :    Rogini A
Users Listed in the sheet :    Mrigashiras
Users Listed in the sheet :    Mirugasirisham
Users Listed in the sheet :    Aardhra
Users Listed in the sheet :    Arudra
Users Listed in the sheet :    Thiruvadhirai
Users Listed in the sheet :    Punarvasu
Users Listed in the sheet :    Punarpoosam
Users Listed in the sheet :    Pushyami
Users Listed in the sheet :    Poosam
Users Listed in the sheet :    Ashlesha
Users Listed in the sheet :    Ayilyam
Users Listed in the sheet :    Magha
Users Listed in the sheet :    Makha
Users Listed in the sheet :    Magam
Users Listed in the sheet :    P.Phalguni
Users Listed in the sheet :    Poorva Phalguni
Users Listed in the sheet :    Pubba
Users Listed in the sheet :    Pooram
Users Listed in the sheet :    U.Phalguni
Users Listed in the sheet :    Uthraphalguni
Users Listed in the sheet :    Uttara
Users Listed in the sheet :    Uthiram
Users Listed in the sheet :    Haatha
Users Listed in the sheet :    Haa tham
Users Listed in the sheet :    Chitra
Users Listed in the sheet :    Chithirai
Users Listed in the sheet :    Swaathi
Users Listed in the sheet :    Swathi
Users Listed in the sheet :    Vishaakha
Users Listed in the sheet :    Visakam
Users Listed in the sheet :    Anuraadha
Users Listed in the sheet :    Anusham
Users Listed in the sheet :    Jyeshta
Users Listed in the sheet :    Kettai
Users Listed in the sheet :    Moola
Users Listed in the sheet :    Moolam
Users Listed in the sheet :    P.Shada
Users Listed in the sheet :    Poorvashaada
Users Listed in the sheet :    Pooradam
Users Listed in the sheet :    U.Shada
Users Listed in the sheet :    Uthrashaada
Users Listed in the sheet :    Uthiradam
Users Listed in the sheet :    Shraavan
Users Listed in the sheet :    Thiruvonam
Users Listed in the sheet :    Dhanishta
Users Listed in the sheet :    Avittam
Users Listed in the sheet :    Shathabhisha
Users Listed in the sheet :    Sathayam
Users Listed in the sheet :    P.Bhadra
Users Listed in the sheet :    Poorvabhadra
Users Listed in the sheet :    Poorattathi
Users Listed in the sheet :    U.Bhadra
Users Listed in the sheet :    Uthrabhadra
Users Listed in the sheet :    Uthirattathi
Users Listed in the sheet :    Revathi s
Users Listed in the sheet :    Revathi a
Users Listed in the sheet :    Hari Prasoon
Users Listed in the sheet :    Bala murugan
Users Listed in the sheet :    Hari prasad


Users Listed in the sheet - Ascending order :
 [Aardhra, Anuraadha, Anusham, Arudra, Ashlesha, Asvini, Aswini, Avittam, Ayilyam, Bala murugan, Bhadra.P, Bhadra.U, Bharani, Chithirai, Chitra, Dhanishta, Haa tham, Haatha, Hari Prasoon, Hari prasad, Jyeshta, Karthigai, Kettai, Krithika, Magam, Magha, Makha, Mirugasirisham, Moola, Moolam, Mrigashiras, Parani, Phalguni.P, Phalguni.U, Pooradam, Pooram, Poorattathi, Poorva Phalguni, Poorvabhadra, Poorvashaada, Poosam, Pubba, Punarpoosam, Punarvasu, Pushyami, Revathi a, Revathi s, Rogini A, Rohini R, Sathayam, Shada.P, Shada.U, Shathabhisha, Shraavan, Swaathi, Swathi, Thiruvadhirai, Thiruvonam, Uthiradam, Uthiram, Uthirattathi, Uthrabhadra, Uthraphalguni, Uthrashaada, Uttara, Visakam, Vishaakha]


Done :-)


Thursday, June 20

Program for Arithmetic operation and basic exception handling techniques using Java

Hi All,


I write a program for Arithmetic operation and basic exception handling techniques for avoid run time errors.

It is used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators:


OperatorDescriptionExample
+Addition - Adds values on either side of the operator A + B will give 30
-Subtraction - Subtracts right hand operand from left hand operand A - B will give -10
*Multiplication - Multiplies values on either side of the operator A * B will give 200
/Division - Divides left hand operand by right hand operand B / A will give 2
%Modulus - Divides left hand operand by right hand operand and returns remainder B % A will give 0







import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Sify
 */
public class arithMetic {

    /* Addtion opertion*/
    public void additionMethod(int num, int num1) {
        System.out.println("Addition operator (+) .");
        System.out.println("Addition of two number : " + (num + num1) + "\n");
    }
    /* Subtraction opertion*/
    public void subtractionMethod(int num, int num1) {
        System.out.println("Subtraction operator (-).");
        System.out.println("Subtraction of two number : " + (num - num1) + "\n");
    }
    /* Multiplication opertion*/
    public void multiplicationMethod(int num, int num1) {
        System.out.println("Multiplication operator (*).");
        System.out.println("Multiplication of two number : " + (num * num1) + "\n");
    }
    /* Division opertion*/
    public void divisionMethod(int num, int num1) {
        System.out.println("Division operator (/).");
        try {
            if (num < num1) {
                System.out.println("Please check the values No " + num + " lessthen No " + num1);
            }
            if (num1 != 0) {
                System.out.println("Division of two number : " + (num / num1) + "\n");
            }

        } catch (Exception e) {
            System.out.println("division by zero not passible :-(");
        }
    }
    /* Modulo opertion*/ 
    public void moduloMethod(int num, int num1) {
        System.out.println("Modulo operator (%).");
        try{
        System.out.println("Modulo of two number : " + (num % num1) + "\n");
        }catch (Exception e) {
            System.out.println("division by zero not passible :-(");
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Please enter the  first number: \t");
        int a = Integer.parseInt(object.readLine());
        System.out.println("\nPlease enter the  Second number: \t");
        int b = Integer.parseInt(object.readLine());
        arithMetic arith = new arithMetic();
        if ((a < 32767) && (b <= 32767)) {
            /*Methods calling*/
            arith.additionMethod(a, b);
            arith.subtractionMethod(a, b);
            arith.multiplicationMethod(a, b);
            arith.divisionMethod(a, b);
            arith.moduloMethod(a, b);
        } else {
            System.out.println("Integer number out of range. Check Again :-(");
        }
    }
}


OUTPUT

~~~~~~~~~

Please enter the  first number:    
10

Please enter the  Second number:    
2
Addition operator (+) .
Addition of two number : 12

Subtraction operator (-).
Subtraction of two number : 8

Multiplication operator (*).
Multiplication of two number : 20

Division operator (/).
Division of two number : 5

Modulo operator (%).
Modulo of two number : 0

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





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