Tuesday, October 1

Simple bank transaction details using basic OOP syntax in java ( Object Oriented programming)

Hi ALL,

Here I wrote a program for simple bank transaction details in based on the concept of  basic OOP syntax (Object Oriented programming) in java.

// Main class
public class bankApp {
    public static void main(String arg[]){
        bankAccountMaintance bam=new bankAccountMaintance(1000.00); //initializing values
        bam.displayAccountSummary(); //display balance
        bam.withdrawal(450.0); //make withdrawal
        bam.displayAccountSummary(); // display balance
        bam.Deposite(10000.0); // make deposit
        bam.displayAccountSummary(); //display balance
       
    }
}

// Sub class
class bankAccountMaintance{
    double balance;  // account balance
    public bankAccountMaintance(double opening_balance){  // constructor
        balance=opening_balance;
    }
    public void Deposite(double de_amt){ // makes deposit
        balance +=de_amt;
    }
    public void withdrawal(double wd_amt){ // makes withdrawal
        balance -=wd_amt;
    }
    public void displayAccountSummary(){ // displays balance
        System.out.println(" Balance amount is "+balance);
    }
}


OUTPUT

 Balance amount is 1000.0
 Balance amount is 550.0
 Balance amount is 10550.0

Thursday, September 26

Multiplication table generation using Java (natural numbers up to 20)

Hi ALL,

I wrote a program for Multiplication table generation using java looping concept (natural numbers up to 20).

public class tables{ 

public static void main(String args[])
 {    
   
    for(int i = 1; i <=20; i++) {
        System.out.println("\n\n"+i +" table\n");
        for(int j = 1; j <= 20; j++) {
            System.out.println(j+" *"+i+" ="+(i*j));
        }               
    }
    
 }

}


OUTPUT:

1 table

1 *1 =1
2 *1 =2
3 *1 =3
4 *1 =4
5 *1 =5
6 *1 =6
7 *1 =7
8 *1 =8
9 *1 =9
10 *1 =10
11 *1 =11
12 *1 =12
13 *1 =13
14 *1 =14
15 *1 =15
16 *1 =16
17 *1 =17
18 *1 =18
19 *1 =19
20 *1 =20


2 table

1 *2 =2
2 *2 =4
3 *2 =6
4 *2 =8
5 *2 =10
6 *2 =12
7 *2 =14
8 *2 =16
9 *2 =18
10 *2 =20
11 *2 =22
12 *2 =24
13 *2 =26
14 *2 =28
15 *2 =30
16 *2 =32
17 *2 =34
18 *2 =36
19 *2 =38
20 *2 =40


3 table

1 *3 =3
2 *3 =6
3 *3 =9
4 *3 =12
5 *3 =15
6 *3 =18
7 *3 =21
8 *3 =24
9 *3 =27
10 *3 =30
11 *3 =33
12 *3 =36
13 *3 =39
14 *3 =42
15 *3 =45
16 *3 =48
17 *3 =51
18 *3 =54
19 *3 =57
20 *3 =60


4 table

1 *4 =4
2 *4 =8
3 *4 =12
4 *4 =16
5 *4 =20
6 *4 =24
7 *4 =28
8 *4 =32
9 *4 =36
10 *4 =40
11 *4 =44
12 *4 =48
13 *4 =52
14 *4 =56
15 *4 =60
16 *4 =64
17 *4 =68
18 *4 =72
19 *4 =76
20 *4 =80


5 table

1 *5 =5
2 *5 =10
3 *5 =15
4 *5 =20
5 *5 =25
6 *5 =30
7 *5 =35
8 *5 =40
9 *5 =45
10 *5 =50
11 *5 =55
12 *5 =60
13 *5 =65
14 *5 =70
15 *5 =75
16 *5 =80
17 *5 =85
18 *5 =90
19 *5 =95
20 *5 =100

etc upto 20th table


Wednesday, September 25

String Class & String manipulation in Java Part-3( Simple Examples for startsWith(),lastIndexOf(),replace(),replaceAll(),replaceFirst(),split() ,hashCode() Methods)

Hi All,

Here I wrote the program for String Class & String manipulation in java using simple examples :)

/* 

startsWith() Method

lastIndexOf() Method

replace() Method 

replaceAll() Method 

replaceFirst() Method 

split() Method 

hashCode() Method

*/

 

import java.lang.String.*;
import java.io.*;
public class stringOperations3 {
    public static void main(String args[]){
       /*String Manipuldation Part-3*/
        
        /* String lastIndexOf() Method
         *  
         * Note:
            1. int lastIndexOf(int ch): Returns the index within this string of the last occurrence of the specified character or -1 if the character does not occur.
            2. public int lastIndexOf(int ch, int fromIndex): Returns the index of the last occurrence of the character in the character sequence represented by this
               object that is less than or equal to fromIndex, or -1 if the character does not occur before that point.
            3. public int lastIndexOf(String str): If the string argument occurs one or more times as a substring within this object,
               then it returns the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.
            4. public int lastIndexOf(String str, int fromIndex): Returns the index within this string of the last occurrence of the specified substring,
               searching backward starting at the specified index.
         */
        String name="SKI Technology in Technopark";
        String cName="no";
        System.out.println("Result of lastIndexOf(int ch) Method :"+name.lastIndexOf('T'));
        System.out.println("Result of lastIndexOf(int ch, int fromIndex) Method :"+name.lastIndexOf('T',4));
        System.out.println("Result of lastIndexOf(String str) Method :"+name.lastIndexOf(cName));
        System.out.println("Result of astIndexOf(String str, int fromIndex)Method :"+name.lastIndexOf(cName,15));
       
        
        /* replace() Method
         *
         * Note: It returns a string derived from this string by replacing every occurrence of oldChar with newChar.
         */
        String val=new String("My Name is skitech");       
        System.out.println("Result of the replace() Method :"+val.replace('s', 'k'));
        System.out.println("Result of the replace() Method :"+val.replace('k', 's'));
        
        /*replaceAll() Method
         *
         * Note: This method replaces each substring of this string that matches the given regular expression with the given replacement.
         */
        String cname="SkiTECH is fantastic";
        System.out.println("Result of the replaceAll() Method :"+cname.replaceAll("SkiTECH","Salem"));
        System.out.println("Result of the replaceAll() Method :"+cname.replaceAll("(.*)is(.*)","Salem"));
        
        /* replaceFirst() Method
         *
         * Note: This method replaces the first substring of this string that matches the given regular expression with the given replacement.
         */
        String cname1="my company name is Skitech in chennai company";
        System.out.println("Result of the replaceFirst() Method :"+cname1.replaceFirst(cname1,"bala"));
        System.out.println("Result of the replaceFirst() Method1 :"+cname1.replaceFirst("company","COMPANY"));
        System.out.println("Result of the replaceFirst() Method2 :"+cname1.replaceFirst("(.*)company(.*)","Skitech"));
        
        /* split() Method
         *
         * Note: It returns the array of strings computed by splitting this string around matches of the given regular expression.
         */
        System.out.println("Result of split() Method");
        String Str = new String("Welcome=to=SKITECH=blog");        
        for (String res: Str.split("="))
            System.out.println(res);
        
        System.out.println("Result of split() Method1");
        for(String res1:Str.split("=", 3))
             System.out.println(res1);
        
        System.out.println("Result of split() Method2");
        for(String res2:Str.split("=", 2))
             System.out.println(res2);
                   
        /*  startsWith() Method
         *
         * Note: It returns true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.
         */
        String temp1="welcome to the SKiTECH";
        System.out.println("Result of startsWith() Method "+temp1.startsWith("welcome"));
        System.out.println("Result of startsWith() Method1 "+temp1.startsWith("to"));
        System.out.println("Result of startsWith() Method2 "+temp1.startsWith("the",11));
        
        /* hashCode() Method
         *
         * Note: This method returns a hash code value for this object.           
         */
        String str1="Ski technology in technopark";       
        System.out.println("Result of hashCode() Method "+str1.hashCode());
    }
    
}

 OUTPUT:


Result of lastIndexOf(int ch) Method :18
Result of lastIndexOf(int ch, int fromIndex) Method :4
Result of lastIndexOf(String str) Method :22
Result of astIndexOf(String str, int fromIndex)Method :8
Result of the replace() Method :My Name ik kkitech
Result of the replace() Method :My Name is ssitech
Result of the replaceAll() Method :Salem is fantastic
Result of the replaceAll() Method :Salem
Result of the replaceFirst() Method :bala
Result of the replaceFirst() Method1 :my COMPANY name is Skitech in chennai company
Result of the replaceFirst() Method2 :Skitech
Result of split() Method
Welcome
to
SKITECH
blog
Result of split() Method1
Welcome
to
SKITECH=blog
Result of split() Method2
Welcome
to=SKITECH=blog
Result of startsWith() Method true
Result of startsWith() Method1 false
Result of startsWith() Method2 true
Result of hashCode() Method 1464026455


String Class & String manipulation in Java Part-2( Simple Examples for substring(),toCharArray(),toLowerCase(),toUpperCase(),toString(),integer to string in java, double to string in java,trim(),indexOf(),intern() Methods )

Hi All,

Here I wrote the program for String Class & String manipulation in java using simple examples :)

  /*

substring() Method

toCharArray() Method

toLowerCase() Method 

toUpperCase() Method 

toString() Method 

integer to string in java 

double to string in java  

trim() Method 

indexOf() Method 

intern() Method 

*/

import java.lang.String.*; 

public class stringOperations2 {
    public static void main(String args[]){
       /*String Manipuldation Part-2*/
       
        /* String substring() Method
         * 
         * Note: The substring begins with the character at the specified index and extends to the end of this string or up to endIndex - 1 if second argument is given.
         */
        String name="SKI Technology";
        String cName=name.substring(0,8);
        System.out.println("CName value in substring() Method :"+cName);
        String cName1=name.substring(4);
        System.out.println("CName1 value is substring() Method (No EndIndex it will take upto endIndex - 1 if second argument is given): "+cName1);
       
        /*  toCharArray() Method
         *
         * Note: This method converts this string to a new character array.
         */
        String val=new String("My Name is SkiTECH");
        char[] b=val.toCharArray();
        System.out.print("Result of the toCharArray() Method ");
        for(char temp: b){
       System.out.print(temp);
    }
       
        /*  String toLowerCase() Method
         *
         * Note: It returns the String, converted to lowercase.
         */
        String cname="SkiTECH";
        System.out.println("\nResult of the String toLowerCase() Method "+cname.toLowerCase());
       
        /* String toUpperCase() Method
         *
         * Note: It returns the String, converted to uppercase.
         */
        String cname1="skitech";
        System.out.println("Result of the String toUpperCase() Method "+cname1.toUpperCase());
       
        /*  toString() Method
         *
         * Note: This method returns the string itself.
         */
        String tname=new String("welcome");
        System.out.println("Result of the toString() Method "+tname.toString());
       
        /*  integer to string in java using toString() method */
        int n=10;
        String sval=Integer.toString(n);
        System.out.println("Integer to string using toString() Method "+sval);
       
        /* double to string in java using toString() method */
        double aDouble = 0.11;
        String sval1 = Double.toString(aDouble);
        System.out.println("Double to string using toString() Method "+sval1);
       
        /*  trim() Method
         *
         * Note: It returns a copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.
         */
        String temp1=" welcome to the SKiTECH          ";
        System.out.println("Result of the trim() Method "+temp1.trim());
       
        /*  indexOf() Method
         *
         * Note:
           1. public int indexOf(int ch): Returns the index within this string of the first occurrence of the specified character or -1 if the character does not occur.
           2. public int indexOf(int ch, int fromIndex): Returns the index within this string of the first occurrence of the specified character, starting the search at
              the specified index or -1 if the character does not occur.
           3. int indexOf(String str): Returns the index within this string of the first occurrence of the specified substring. If it does not occur as a substring, -1 is returned.
           4. int indexOf(String str, int fromIndex): Returns the index within this string of the first occurrence of the specified substring,
              starting at the specified index. If it does not occur, -1 is returned.
         */
        String str1="Ski technology in technopark";
        String str2="tech";
        System.out.println("Result of indexOf(int ch) method "+str1.indexOf('t'));
        System.out.println("Result of indexOf(int ch, int fromIndex) method "+str1.indexOf('o',13));
        System.out.println("Result of indexOf(String str) method "+str1.indexOf(str2));
        System.out.println("Result of indexOf(String str, int fromIndex) method "+str1.indexOf(str2, 10));
       
        /*  intern() Method
         *
         * Note: This method Returns a canonical representation for the string object.
         */
        String str3="welcome To Skitech";
        System.out.println("Result of the intern() Method "+str3.intern());
    }
   
}

  OUTPUT:

CName value in substring() Method :SKI Tech
CName1 value is substring() Method (No EndIndex it will take upto endIndex - 1 if second argument is given): Technology
Result of the toCharArray() Method My Name is SkiTECH
Result of the String toLowerCase() Method skitech
Result of the String toUpperCase() Method SKITECH
Result of the toString() Method welcome
Integer to string using toString() Method 10
Double to string using toString() Method 0.11
Result of the trim() Method welcome to the SKiTECH
Result of indexOf(int ch) method 4
Result of indexOf(int ch, int fromIndex) method 23
Result of indexOf(String str) method 4
Result of indexOf(String str, int fromIndex) method 18
Result of the intern() Method welcome To Skitech

Wednesday, September 18

String Class & String manipulation in Java Part-1( Simple Examples for Character array values in String,Length Method,Concatenating Method,charAt(),compareTo(),compareToIgnoreCase(),contentEquals() Methods )

Hi All,

Here I wrote the program for String Class & String manipulation in java using simple examples :)

/*

character array values in String

Length Method 

Concatenating Method 

charAt() Method 

compareTo() Method 

compareToIgnoreCase() Method 

contentEquals() Method 

*/

import java.lang.String.*;

public class stringOperations {
    public static void main(String args[]){
        /* Using character array values in String method*/
       
        char[] var1={'a','b','c','d'};
        String val=new String(var1);
        System.out.println("character array values  :" + val);
       
        /* Length Method
         *
         * Note: It used to finding Length of the string values
         */

       
        String statement="Welcome to the string method";
        System.out.println("Length of the statement string  is "+statement.length());
       
        /*  Concatenating Method
         * 
         * Note: This method appends one String to the end of another String.
         */

        String fname="SKi";
        String lname="TECH";
        String username=fname.concat(lname);
        System.out.println("Concatenation of the Strings "+username);
       
        /*  charAt() Method
         *
         * Note: This method returns the character located at the String's specified index. The string indexes start from zero.
         */

       
        String statement1="Welcome to the string method";
        char res=statement1.charAt(11);
        System.out.println("The specified index of String is "+ res);
       
        /*  compareTo() Method
         *
         *  There are two variants of this method. First method compares this String to another Object and second method compares two strings lexicographically.
         *  Note: 
         *  Less than zero (<0)         The invoking string is less than string.
            Greater than zero (>0)    The invoking string is greater than string.
            Zero (0)                    The two strings are equal. 

         */

        String small_name="skitech";
        String uppername="SKITECH";
        String name="SKITECH";
        int result=small_name.compareTo(uppername);
        System.out.println("Result of compareTo method "+result);
        int result1=uppername.compareTo(name);
        System.out.println("Reault1 of compareTo method "+result1);
       
        /* compareToIgnoreCase() Method
         *
         * Note: This method compares two strings lexicographically, ignoring case differences.
         */

        int result2=small_name.compareToIgnoreCase(uppername);
        System.out.println("Result2 of compareToIgnoreCase method (ignoring case differences) "+result2);
        int result3=uppername.compareToIgnoreCase(name);
        System.out.println("Result3 of compareToIgnoreCase mathod (ignoring case differences) "+result3);
       
        /* contentEquals() Method
         *
         * Note: This method returns true if and only if this String represents the same sequence of characters as the specified in StringBuffer(Equally same), otherwise false.
         */

        String findstring="Skitech";
        StringBuffer statement4=new StringBuffer("Skitech Corporation is an Indian software corporation headquartered in Chennai, "
                + " that develops, manufactures, licenses, and supports a wide range of products and services related to computing. "
                + " The company was founded by Balamurugan and Sri on April 1, 2010. "
                + " Skitech is the world's largest software maker ");
        StringBuffer statement5=new StringBuffer("Skitech");
        Boolean content1=findstring.contentEquals(statement4);
        System.out.println("Content1 contentEquals() Method is  "+content1);
        boolean content2=findstring.contentEquals(statement5);
        System.out.println("Content2  contentEquals() Method is "+content2);
    }
   
}


output:

character array values  :abcd
Length of the statement string  is 28
Concatenation of the Strings SKiTECH
The specified index of String is t
Result of compareTo method 32
Reault1 of compareTo method 0
Result2 of compareToIgnoreCase method (ignoring case differences) 0
Result3 of compareToIgnoreCase mathod (ignoring case differences) 0
Content1 contentEquals() Method is  false
Content2  contentEquals() Method is true

Tuesday, July 16

Basic functionality of Preg_match in PHP with various scenarios and its example

Hi All,

Basic regexps with preg_match()

syntax:


int preg_match ( string pattern, string subject [, array matches [, int flags [, int offset]]])


preg_match() and takes two parameters: the pattern to match, and the string to match it against.

Preg_match() will apply the regular expression in parameter one to the string in parameter two and see whether it finds a match - if it does, it will return 1, otherwise 0. 

 Regular expressions are formed by starting with a forward slash /, followed by a sequence of special symbols and words to match, then another slash and, optionally, a string of letters that affect the expression.  

Note:

  •   The “i” used to find  pattern delimiter indicates a case-insensitive search.

  •  The “\b”used to find pattern indicates a word boundary, so only the distinct.

 

<?php
echo "<br>Basic preg_match Functionality <br><br> ";
echo "example 1 for Case Sensitive Search <br>";
if(preg_match("/cool/", "I love to share Cool things that help others.")){
        echo "matched text<br>";
} else {
        echo "Not Matched text<br>";
}

echo "<br> example 2 for Case Insensitive  Search<br>";
if(preg_match("/bala/i", "my name is Balamurugan shortly call has a Bala")){
        echo "name found in text<br>";
}else{
        echo "name is not found in text<br>";
}


echo "<br> example 3 for Word boundary <br>";
if(preg_match("/\bkrishna\b/i",  "Krishna is a god. he kills kamsan in long long ago. and Krishna became king" )){
    echo " krishna name <br>";
}else{
    echo " krishna name not found<br>";
}

echo "<br> example 4 for Found string matched <br>";
if(preg_match("/[Ff]oo/","foo")){
    echo 'string matched<br>';
}  else {
    echo 'String not matched<br>';
}

echo "<br> example 5 for Found string unmatched <br>";
if(preg_match("/[^Ff]oo/","foo")){
    echo 'string matched<br>';
}  else {
    echo 'String not matched<br>';
}

echo "<br> example 6 for Alpha Numeric <br>";
if(preg_match("/[0-9,A-Z,a-z]/","foo")){
    echo 'It is Alphanumeric<br>';
}  else {
    echo 'It is not Alphanumeric<br>';
}

echo "<br> example 7 for Numeric <br>";
if(preg_match("/[0-9]/","foo")){
    echo 'It is Numeric<br>';
}  else {
    echo 'It is not Numeric<br>';
}

echo "<br> example 8 for Lowercase of string <br>";
if(preg_match("/[a-z]/","fo0")){
    echo 'It is Lowercase<br>';
}  else {
    echo 'It is not Lowercase<br>';
}

echo "<br> example 9 for Uppercase of string <br>";
if(preg_match("/[A-Z]/","foo")){
    echo 'It is uppercase<br>';
}  else {
    echo 'It is not Uppercase<br>';
}

echo "<br> example 10 for matched of character in string <br>";
if(preg_match("/[a-w]orld/","aorld")){
    echo 'It is matched<br>';
}  else {
    echo 'It is not matched<br>';
}

echo "<br> example 11 for matched of character & number in string <br>";
if(preg_match("/[a-t]est[0-9][0-9]/","west33")){
    echo 'It is matched<br>';
}  else {
    echo 'It is not matched<br>';
}

echo "<br> example 12 for matched of character & number in string in_casesensitive <br>";
if(preg_match("/[a-t]est[0-9][0-9]/i","West33")){
    echo 'It is matched<br>';
}  else {
    echo 'It is not matched<br>';
}

echo "<br> example 13 for not matched of character & number in string <br>";
if(preg_match("/[^a-t]est[0-9][0-9]/","Best33")){
    echo 'It is matched<br>';
}  else {
    echo 'It is not matched<br>';
}

echo "<br> example 14 for not matched of character & number in string in_casesensitive <br>";
if(preg_match("/[^a-t]est[0-9][0-9]/i","Best33")){
    echo 'It is matched<br>';
}  else {
    echo 'It is not matched<br>';
}

?>

OUTPUT

~~~~~~~~



Basic Preg_Match Functionality

example 1 for Case Sensitive Search
Not Matched text

example 2 for Case Insensitive Search
name found in text

example 3 for Word boundary
krishna name

example 4 for Found string matched
string matched

example 5 for Found string unmatched
String not matched

example 6 for Alpha Numeric
It is Alphanumeric

example 7 for Numeric
It is not Numeric

example 8 for Lowercase of string
It is Lowercase

example 9 for Uppercase of string
It is not Uppercase

example 10 for matched of character in string
It is matched

example 11 for matched of character & number in string
It is not matched

example 12 for matched of character & number in string in_casesensitive
It is not matched

example 13 for not matched of character & number in string
It is matched

example 14 for not matched of character & number in string in_casesensitive
It is not matched
 

Tuesday, July 2

What really happens when you navigate to a URL

Hi All,

I  learn the "What really happens when you navigate to a URL" in net. I really like to share this every one. it is simply and very good process going behind in each request. 


As a software developer, you certainly have a high-level picture of how web apps work and what kinds of technologies are involved: the browser, HTTP, HTML, web server, request handlers, and so on.
In this article, we will take a deeper look at the sequence of events that take place when you visit a URL.

1. You enter a URL into the browser

It all starts here:
image

2. The browser looks up the IP address for the domain name

 image
The first step in the navigation is to figure out the IP address for the visited domain. The DNS lookup proceeds as follows:

  • Browser cache – The browser caches DNS records for some time. Interestingly, the OS does not tell the browser the time-to-live for each DNS record, and so the browser caches them for a fixed duration (varies between browsers, 2 – 30 minutes).
  • OS cache – If the browser cache does not contain the desired record, the browser makes a system call (gethostbyname in Windows). The OS has its own cache.
  • Router cache – The request continues on to your router, which typically has its own DNS cache.
  • ISP DNS cache – The next place checked is the cache ISP’s DNS server. With a cache, naturally.
  • Recursive search – Your ISP’s DNS server begins a recursive search, from the root nameserver, through the .com top-level nameserver, to Facebook’s nameserver. Normally, the DNS server will have names of the .com nameservers in cache, and so a hit to the root nameserver will not be necessary.
Here is a diagram of what a recursive DNS search looks like:
500px-An_example_of_theoretical_DNS_recursion_svg
One worrying thing about DNS is that the entire domain like wikipedia.org or facebook.com seems to map to a single IP address. Fortunately, there are ways of mitigating the bottleneck:
  • Round-robin DNS is a solution where the DNS lookup returns multiple IP addresses, rather than just one. For example, facebook.com actually maps to four IP addresses.
  • Load-balancer is the piece of hardware that listens on a particular IP address and forwards the requests to other servers. Major sites will typically use expensive high-performance load balancers.
  • Geographic DNS improves scalability by mapping a domain name to different IP addresses, depending on the client’s geographic location. This is great for hosting static content so that different servers don’t have to update shared state.
  • Anycast is a routing technique where a single IP address maps to multiple physical servers. Unfortunately, anycast does not fit well with TCP and is rarely used in that scenario.
Most of the DNS servers themselves use anycast to achieve high availability and low latency of the DNS lookups.

3. The browser sends a HTTP request to the web server

image
You can be pretty sure that Facebook’s homepage will not be served from the browser cache because dynamic pages expire either very quickly or immediately (expiry date set to past).
So, the browser will send this request to the Facebook server:
GET http://facebook.com/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, [...]
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...]
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: facebook.com
Cookie: datr=1265876274-[...]; locale=en_US; lsd=WW[...]; c_user=2101[...]
The GET request names the URL to fetch: “http://facebook.com/”. The browser identifies itself (User-Agent header), and states what types of responses it will accept (Accept and Accept-Encoding headers). The Connection header asks the server to keep the TCP connection open for further requests.
The request also contains the cookies that the browser has for this domain. As you probably already know, cookies are key-value pairs that track the state of a web site in between different page requests. And so the cookies store the name of the logged-in user, a secret number that was assigned to the user by the server, some of user’s settings, etc. The cookies will be stored in a text file on the client, and sent to the server with every request.
There is a variety of tools that let you view the raw HTTP requests and corresponding responses. My favorite tool for viewing the raw HTTP traffic is fiddler, but there are many other tools (e.g., FireBug) These tools are a great help when optimizing a site.
In addition to GET requests, another type of requests that you may be familiar with is a POST request, typically used to submit forms. A GET request sends its parameters via the URL (e.g.: http://robozzle.com/puzzle.aspx?id=85). A POST request sends its parameters in the request body, just under the headers.
The trailing slash in the URL “http://facebook.com/” is important. In this case, the browser can safely add the slash. For URLs of the form http://example.com/folderOrFile, the browser cannot automatically add a slash, because it is not clear whether folderOrFile is a folder or a file. In such cases, the browser will visit the URL without the slash, and the server will respond with a redirect, resulting in an unnecessary roundtrip.

4. The facebook server responds with a permanent redirect

image
This is the response that the Facebook server sent back to the browser request:
HTTP/1.1 301 Moved Permanently
Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0,
      pre-check=0
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Location: http://www.facebook.com/
P3P: CP="DSP LAW"
Pragma: no-cache
Set-Cookie: made_write_conn=deleted; expires=Thu, 12-Feb-2009 05:09:50 GMT;
      path=/; domain=.facebook.com; httponly
Content-Type: text/html; charset=utf-8
X-Cnection: close
Date: Fri, 12 Feb 2010 05:09:51 GMT
Content-Length: 0
The server responded with a 301 Moved Permanently response to tell the browser to go to “http://www.facebook.com/” instead of “http://facebook.com/”.
There are interesting reasons why the server insists on the redirect instead of immediately responding with the web page that the user wants to see.
One reason has to do with search engine rankings. See, if there are two URLs for the same page, say http://www.igoro.com/ and http://igoro.com/, search engine may consider them to be two different sites, each with fewer incoming links and thus a lower ranking. Search engines understand permanent redirects (301), and will combine the incoming links from both sources into a single ranking.
Also, multiple URLs for the same content are not cache-friendly. When a piece of content has multiple names, it will potentially appear multiple times in caches.

5. The browser follows the redirect

image
The browser now knows that “http://www.facebook.com/” is the correct URL to go to, and so it sends out another GET request:
GET http://www.facebook.com/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, [...]
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...]
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Cookie: lsd=XW[...]; c_user=21[...]; x-referer=[...]
Host: www.facebook.com
The meaning of the headers is the same as for the first request.

6. The server ‘handles’ the request

image
The server will receive the GET request, process it, and send back a response.
This may seem like a straightforward task, but in fact there is a lot of interesting stuff that happens here – even on a simple site like my blog, let alone on a massively scalable site like facebook.
  • Web server softwareThe web server software (e.g., IIS or Apache) receives the HTTP request and decides which request handler should be executed to handle this request. A request handler is a program (in ASP.NET, PHP, Ruby, …) that reads the request and generates the HTML for the response. In the simplest case, the request handlers can be stored in a file hierarchy whose structure mirrors the URL structure, and so for example http://example.com/folder1/page1.aspx URL will map to file /httpdocs/folder1/page1.aspx. The web server software can also be configured so that URLs are manually mapped to request handlers, and so the public URL of page1.aspx could be http://example.com/folder1/page1.
  • Request handlerThe request handler reads the request, its parameters, and cookies. It will read and possibly update some data stored on the server. Then, the request handler will generate a HTML response.
One interesting difficulty that every dynamic website faces is how to store data. Smaller sites will often have a single SQL database to store their data, but sites that store a large amount of data and/or have many visitors have to find a way to split the database across multiple machines. Solutions include sharding (splitting up a table across multiple databases based on the primary key), replication, and usage of simplified databases with weakened consistency semantics.
One technique to keep data updates cheap is to defer some of the work to a batch job. For example, Facebook has to update the newsfeed in a timely fashion, but the data backing the “People you may know” feature may only need to be updated nightly (my guess, I don’t actually know how they implement this feature). Batch job updates result in staleness of some less important data, but can make data updates much faster and simpler.

7. The server sends back a HTML response

image
Here is the response that the server generated and sent back:
HTTP/1.1 200 OK
Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0,
    pre-check=0
Expires: Sat, 01 Jan 2000 00:00:00 GMT
P3P: CP="DSP LAW"
Pragma: no-cache
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
X-Cnection: close
Transfer-Encoding: chunked
Date: Fri, 12 Feb 2010 09:05:55 GMT

2b3
��������T�n�@����[...]
The entire response is 36 kB, the bulk of them in the byte blob at the end that I trimmed.
The Content-Encoding header tells the browser that the response body is compressed using the gzip algorithm. After decompressing the blob, you’ll see the HTML you’d expect:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" 
      lang="en" id="facebook" class=" no_js">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-language" content="en" />
...
In addition to compression, headers specify whether and how to cache the page, any cookies to set (none in this response), privacy information, etc.
Notice the header that sets Content-Type to text/html. The header instructs the browser to render the response content as HTML, instead of say downloading it as a file. The browser will use the header to decide how to interpret the response, but will consider other factors as well, such as the extension of the URL.

8. The browser begins rendering the HTML

Even before the browser has received the entire HTML document, it begins rendering the website:
 image

9. The browser sends requests for objects embedded in HTML

image
As the browser renders the HTML, it will notice tags that require fetching of other URLs. The browser will send a GET request to retrieve each of these files.
Here are a few URLs that my visit to facebook.com retrieved:
  • Imageshttp://static.ak.fbcdn.net/rsrc.php/z12E0/hash/8q2anwu7.gif
    http://static.ak.fbcdn.net/rsrc.php/zBS5C/hash/7hwy7at6.gif
  • CSS style sheetshttp://static.ak.fbcdn.net/rsrc.php/z448Z/hash/2plh8s4n.css
    http://static.ak.fbcdn.net/rsrc.php/zANE1/hash/cvtutcee.css
  • JavaScript files
    http://static.ak.fbcdn.net/rsrc.php/zEMOA/hash/c8yzb6ub.js
    http://static.ak.fbcdn.net/rsrc.php/z6R9L/hash/cq2lgbs8.js
Each of these URLs will go through process a similar to what the HTML page went through. So, the browser will look up the domain name in DNS, send a request to the URL, follow redirects, etc.
However, static files – unlike dynamic pages – allow the browser to cache them. Some of the files may be served up from cache, without contacting the server at all. The browser knows how long to cache a particular file because the response that returned the file contained an Expires header. Additionally, each response may also contain an ETag header that works like a version number – if the browser sees an ETag for a version of the file it already has, it can stop the transfer immediately.
Can you guess what “fbcdn.net” in the URLs stands for? A safe bet is that it means “Facebook content delivery network”. Facebook uses a content delivery network (CDN) to distribute static content – images, style sheets, and JavaScript files. So, the files will be copied to many machines across the globe.
Static content often represents the bulk of the bandwidth of a site, and can be easily replicated across a CDN. Often, sites will use a third-party CDN provider, instead of operating a CND themselves. For example, Facebook’s static files are hosted by Akamai, the largest CDN provider.
As a demonstration, when you try to ping static.ak.fbcdn.net, you will get a response from an akamai.net server. Also, interestingly, if you ping the URL a couple of times, may get responses from different servers, which demonstrates the load-balancing that happens behind the scenes.

10. The browser sends further asynchronous (AJAX) requests

image

In the spirit of Web 2.0, the client continues to communicate with the server even after the page is rendered.

For example, Facebook chat will continue to update the list of your logged in friends as they come and go. To update the list of your logged-in friends, the JavaScript executing in your browser has to send an asynchronous request to the server. The asynchronous request is a programmatically constructed GET or POST request that goes to a special URL. In the Facebook example, the client sends a POST request to http://www.facebook.com/ajax/chat/buddy_list.php to fetch the list of your friends who are online.

This pattern is sometimes referred to as “AJAX”, which stands for “Asynchronous JavaScript And XML”, even though there is no particular reason why the server has to format the response as XML. For example, Facebook returns snippets of JavaScript code in response to asynchronous requests..

Conclusion

Hopefully this gives you a better idea of how the different web pieces work together.

Converting CSV File in to Excel File Using JAVA

Hi ALL,

Here I write a program for Convert the CSV file to MS Excel file using JAVA.


/*Import  file declaration*/

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.*;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import java.io.*;

public class csvTOexcel {

    public static void main(String args[]) throws IOException {
        ArrayList arrayList = null;
        ArrayList al = null;

        String FileName = "C:\\Documents and Settings\\SKitech\\Desktop\\bala\\auto_reg.csv"; //Source file name & path
        String CLine;
        int count = 0;

        FileInputStream fis = new FileInputStream(FileName);
        DataInputStream dis = new DataInputStream(fis);
        int i = 0;
        arrayList = new ArrayList();
        while ((CLine = dis.readLine()) != null) {
            al = new ArrayList();
            String strar[] = CLine.split(",");
            for (int j = 0; j < strar.length; j++) {
                al.add(strar[j]);
            }
            arrayList.add(al);
            System.out.println(al); // Write a values in console
            i++;
        }

        try {
            HSSFWorkbook hwb = new HSSFWorkbook();
            HSSFSheet sheet = hwb.createSheet("My Sheet");
            for (int k = 0; k < arrayList.size(); k++) {
                ArrayList ardata = (ArrayList) arrayList.get(k);
//System.out.println("ardata " + ardata.size());
                HSSFRow row = sheet.createRow((short) 0 + k);
                for (int p = 0; p < ardata.size(); p++) {
//System.out.print(ardata.get(p));
                    HSSFCell cell = row.createCell((short) p);
                    cell.setCellValue(ardata.get(p).toString());
                }
                System.out.println();
            }
            FileOutputStream fileOut = new FileOutputStream("C:\\xls\\auto_reg1.xls");
            hwb.write(fileOut);
            fileOut.close();
            System.out.println("Your excel file has been generated");
        } catch (Exception ex) {
        } //main method ends
    }
}

OUTPUT:

~~~~~~~~~


[00079584, 00052705, The Five C's of Writing in Today's Business Environment, AYDINBE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BASAREV1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BEEREBA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BEIJEED1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BENTRO1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BEZEMRI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BLOKHAR1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BOESSNA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BOLRO1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BOMHOVA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BONNIPA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BOSCHPE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BOUKHSA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BRANDKA4]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BRESHA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BRUENFR1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BRUGTHI2]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, BUITEAP1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, CLAASRE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, DAALMDA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, DAAMEIN1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, DACHAHE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, DEBETPE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, DEKKECA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, DIJKHHA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, DUNNIFL1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, EDELSEL1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, EIMERFR1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, ENGERSA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, ENTINHA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, ERMERAN1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, FAOUZJA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, FRANKST5]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, FREEHA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, GILSAD1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, GRAAFHA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, GRAAFMA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, GRAAFSI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, GRAATKA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, GREFTWI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HAANDA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HALIESA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HARTOBR1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HAVELWE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HEERDLI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HILTECA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HOGARAL1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HORDIAA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, HULTEDE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, IJZERCA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, IMHOFLI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, JANSSRO1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, JURAWRA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, KEMPEAN3]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, KETELMA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, KLAWEIN1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, KLEINAN4]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, KUENEEL1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, KUNSTVI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, LATERSU1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, LEMOUMO1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, LIEASMO1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, LIERELO1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, LOHBEMI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, LOOHUEL1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, MARIVI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, MOKHTAH1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, NEUMAPA2]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, NIEUWKA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, NOBELSU2]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, PENNIHA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, PERUMDE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, PLUIMWI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, RAADDE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, RAADPI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, RAVELLE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, RENETNA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, RIETVJO1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, ROOYLI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, ROSBE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, RUISBNI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, SCHONJA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, SCHRADA3]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, SILVEJU1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, STOLTLE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, SWINKRA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, TAHAPSU2]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, THOBEED1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, VALKCH1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, VANDEEV3]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, VERHORE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, VERKOCA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, VRIESGI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, VRIESMA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, WESTEPI1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, WILKSA1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, WILTEFE1]
[00079584, 00052705, The Five C's of Writing in Today's Business Environment, WITLOME1]



this Data write in Excel File.


Your excel file has been generated

PHP Search Engine using Ajax,Jquery Technologies


Hi All,

Here I write a simple project for Search Engine using PHP, Ajax, Jquery and MySql.


1. This is a very simple search engine to search the records in single tables within the database. If you want you can add more tables according to your request.


2. The Search Engine shows tables values in the table format by clicking the Search button.


 Requirements details:


    Go to Site: http://jquery.com/download/

    And select then download the "Download the uncompressed, development jQuery 1.10.1" .

    Place it inside in your project JS folder. 


 Steps details:


Database details:


 1. create new database in MySQL.


2. in side the database create new table.


Example Db Structure:

/* Create DB Code*/

DROP DATABASE IF EXISTS `balabms`;

CREATE DATABASE IF NOT EXISTS `balabms` ;

USE `balabms`;

/*Create Table Code*/

DROP TABLE IF EXISTS `bmsbook`;

CREATE TABLE IF NOT EXISTS `bmsbook` (

  `bid` int(11) NOT NULL,

  `bname` varchar(32) NOT NULL,

  `auth` varchar(32) NOT NULL,

  `pub` varchar(32) NOT NULL,

  `cat` varchar(32) NOT NULL,

  `qty` int(11) NOT NULL,

  `price` double NOT NULL,

  KEY `bid` (`bid`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/* Insert value to the Table*/

INSERT INTO `bmsbook` (`bid`, `bname`, `auth`, `pub`, `cat`, `qty`, `price`) VALUES

    (0, 'Programming in c', 'Dennis Rechie', 'At&t', 'Computers', 60, 499),

   (1, 'java', 'bala', 'Skitech', '3', 50, 150),

   (2, 'C++', 'SRI', 'Skitech', '26', 15, 120),

   (3, 'PHP', 'RAJA', 'Skitech', '30', 20, 220),

   (4, 'AJAX', 'KRISH', 'Skitech', '11', 30, 450),

   (5, 'JQUERY', 'ROCK', 'Skitech', '15', 45, 650);

Index.PHP
~~~~~~~~~~


<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <script src="js/jquery-1.10.1.js"></script>
       
        <!-- Ajax and Jquery Call for Search -->
       
        <script type="text/javascript">
            $(document).ready(function() {

                function search() {

                    var title = $("#search").val();

                    if (title != "") {

                        $.ajax({
                            type: "get",
                            url: "search.php",   <!-- Redirect Function  -->
                            data: "title=" + title,
                            success: function(data) {
                                $("#result").html(data);
                                $("#search").val("");
                            }
                        });
                    }
                }

                $("#button").click(function() {
                    search();
                });

                $('#search').keyup(function(e) {
                    if (e.keyCode == 13) {
                        search();
                    }
                });
            });
        </script> 
       
<!-- Internal style sheet for Search textbox and button -->

        <style type="text/css">
            #container{
                width:800px;
                margin:0 auto;
            }

            #search{
                width:350px;
                padding:10px;
            }

            #button{
                display: block;
                width: 100px;
                height:30px;
                border:solid #366FEB 1px;
                background: #d4e3e5;
            }

            ul{
                margin-left:-40px;
            }

            ul li{
                list-style-type: none;
                border-bottom: dotted 1px black;
                height: 50px;
            }

            li:hover{
                background: #A592E8;
            }

            a{
                text-decoration: none;
                font-size: 18px;
            }
        </style>
    </head>

    <!-- Define Search textbox and button -->


    <body>
        <div id="container">
            <input type="text" id="search" placeholder="Search Books name Here..."/>
            <input type="button" id="button" value="Search" />
           
        <!-- Result place -->   
       
            <ul id="result"></ul>
        </div>
    </body>
</html>

Search.php

~~~~~~~~~~~


<!-- Style sheet for fancy Table Format -->

 <style type="text/css">
table.hovertable {
    font-family: verdana,arial,sans-serif;
    font-size:11px;
    color:#333333;
    border-width: 1px;
    border-color: #999999;
    border-collapse: collapse;
}
table.hovertable th {
    background-color:#c3dde0;
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #a9c6c9;
}
table.hovertable tr {
    background-color:#d4e3e5;
}
table.hovertable td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #a9c6c9;
}
</style>

<?php

/* Database Connection Method*/

  mysql_connect("localhost","root","") or die("Unable to connect Database");
  mysql_select_db("balabms") or die("error in Database name");

/*Fetching Search result Query*/

$result = "select * from bmsbook where bname like '%".$_GET['title']."%' or auth like '%".$_GET['title']."%' or
                bid like '%".$_GET['title']."%' or pub like '%".$_GET['title']."%' or cat like '%".$_GET['title']."%'";
    $res = mysql_query($result);
    $rec_count = mysql_num_rows($res);      

/*Checking the query contains value or Not */
    
if($rec_count>0){
    ?>
<table class="hovertable">
<tr>
    <th>Book ID</th>
    <th>Book Name</th>
    <th>Author</th>
    <th>Publisher</th>
    <th>Catagory</th>  
</tr>

<!-- IF contanis  records (Result) It will Display in fancy Table Format -->

<?php while ($row =mysql_fetch_row($res)){ ?>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
    <td><?php echo $row[0]; ?></td>
        <td><?php echo $row[1]; ?></td>
        <td><?php echo $row[2]; ?></td>
        <td><?php echo $row[3]; ?></td>
        <td><?php echo $row[4]; ?></td>
</tr>
        <?php } } else{ ?>

<!-- IF contanis not records (No Result) It will Display in fancy Table Format -->

       
</table>
        <table class="hovertable">
  <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
    <td style="padding: 8px 140px;"><?php echo "No Records Found"; ?></td>
    
</tr>
        <?php }?>
</table>

 

OUTPUT

~~~~~~~~~


Result found:
 


Result not found:




  

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