Thursday, August 7, 2014

Difference between print_r and var_dump

The var_dump function displays structured information about variables/expressions including its type andvalue. Arrays are explored recursively with values indented to show structure. It also shows which array values and object properties are references.
The print_r() displays information about a variable in a way that's readable by humans. array values will be presented in a format that shows keys and elements. Similar notation is used for objects.



print_r(null) will return nothing where as var_dump(null) returns NULL which is useful when debugging
Example:

<?php

//$obj = (object) array('qualitypoint', 'technologies', 'India');

$obj =array('qualitypoint', 'technologies', 'India');
//var_dump($obj) will display below output in the screen.



echo "<br>var_dump out put<BR>";
var_dump($obj);
//var_dump(0);
var_dump($obj[0]);

/*
object(stdClass)#1 (3) {
 [0]=> string(12) "qualitypoint"
 [1]=> string(12) "technologies"
 [2]=> string(5) "India"
} */
//And, print_r($obj) will display below output in the screen.
echo "<br>Print_r out put<BR>";
print_r($obj);
print_r($obj[0]);
/*stdClass Object (
 [0] => qualitypoint
 [1] => technologies
 [2] => India
) */

?>

Tuesday, July 29, 2014

Find second largest value / Salary using Mysql

Using Sub query

Option Query 1

  SELECT MAX(salary) FROM emp WHERE salary NOT IN
 (SELECT MAX(salary) FROM emp)


Option Query 2


     SELECT MAX(salary) FROM emp WHERE salary <(SELECT MAX(salary) FROM emp)

Option Query 3
    SELECT MIN (salary) FROM emp WHERE salary in (SELECT TOP 2 (salary) FROM emp ORDER BY salary DESC)

Monday, July 28, 2014

Difference between parent() vs parents()

Below code clarify some differences between the parent() and parents() methods.

parent(selector) : This returns the one immediate parent of the element. Selector is passed in only required cases, like if we want to check if parent exists for the element or in some other situations. Here is simple example which illustrates the parent method.



parents(selector) : This returns the multiple ancestors. Its not restricted to only one level of parent/ancestors of the element. This is the main difference between the parent and parents method.

For Examples 1
<html>…<body><div class=”one”><div class=”two”><p><span>Some text</span></p></div></div></body></html>

$(‘span’).parent() will select the <p> tag such that the element set in the jQuery object is [span].

$(‘span’).parents() will select all parent tags such that the element set in the jQuery object is [p, div.two, div.one, body, html].

So parent() will select the first parent element while parents() will select all elements straight up the DOM tree.

The .parents() and .parent() methods are similar, except that the latter only travels a single level up the DOM tree. Also, $( "html" ).parent() method returns a set containing document whereas $( "html" ).parents() returns an empty set.


For Examples 2


HTML Code

<!DOCTYPE html>
<html lang="en">
  <head>
     <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  </head>
  <body>
     <div>
        <p>
            <a href="#" id="anchorTag">Click here</a>
         </p>
      </div>
   </body>
</html>


jQuery  For parent()
   $('#anchorTag').parent();      //This would return p, immediate parent of a#anchorTag.


jQuery  For parents()
   $('#anchorTag').parents();        //This would return all the ancestors (p, div, body, html)

   //On passing selector it will filter down the matched parent elements by selector

   $('#anchorTag').parents('div');   //This would give me only div




 closest(selector) : It works like parents(), except that it returns only one parent/ancestor. This is ideal for the situation i mentioned earlier. If i want to check for existence of element in the ancestry tree, then i would prefer to use the closest rather than parents as it only target the selector rather than filtering it from all the ancestor elements. Here is example

$('#anchorTag').closest();           //This would give me empty object as we have not mentioned the selector
$('#anchorTag').closest('div');      //This would give me the div.

Tuesday, July 22, 2014

Extract XML Data using JavaScript

This code is very useful Extract XML Data using JavaScript.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Extract XML Data using JavaScript </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>Extract XML Data using JavaScript</title>

        <style>
            #books
            {
                font:13px Arial;
                width:590px;
                text-align:center;
                border:solid 1px #000;
                overflow:hidden;
            }
            #books div
            {
                width:180px;
                text-align:left;
                border:solid 1px #000;
                margin:1px;
                padding:2px 5px;
            }
           
            .col1 {float:left;clear:both;}
            .col2 {float:left;}
 .col4 {float:right;}
           
        </style>
    </head>
<body>
    <div id="books"></div>
       
    <script type="text/javascript">

        var oXHR = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');

        function reportStatus() {
            if (oXHR.readyState == 4)               // REQUEST COMPLETED.
                showTheList(this.responseXML);      // ALL SET. NOW SHOW XML DATA.
        }

        oXHR.onreadystatechange = reportStatus;
       
        oXHR.open("GET", "lib.xml", true);     
                    // true = ASYNCHRONOUS REQUEST (DESIRABLE), false = SYNCHRONOUS REQUEST.
        oXHR.send();

        function showTheList(xml) {

            var divBooks = document.getElementById('books');        // THE PARENT DIV.
            var Book_List = xml.getElementsByTagName('List');       // THE XML TAG NAME.

            for (var i = 0; i < Book_List.length; i++) {

                // CREATE CHILD DIVS INSIDE THE PARENT DIV.
                var divLeft = document.createElement('div');
                divLeft.className = 'col1';
                divLeft.innerHTML = Book_List[i].getElementsByTagName("BookName")[0].childNodes[0].nodeValue;

                var divRight = document.createElement('div');
                divRight.className = 'col2';
                divRight.innerHTML = Book_List[i].getElementsByTagName("Category")[0].childNodes[0].nodeValue;




     var divRightnew = document.createElement('div');
                divRightnew.className = 'col4';
                divRightnew.innerHTML = Book_List[i].getElementsByTagName("Price")[0].childNodes[0].nodeValue;


                // ADD THE CHILD TO THE PARENT DIV.
                divBooks.appendChild(divLeft);
                divBooks.appendChild(divRight);
                     divBooks.appendChild(divRightnew);
            }
        };

    </script>
</body>
</html>



After create xml file "lib.xml" 
<?xml version="1.0"?>
<!--  Last edited by http://encodedna.com  -->
<Library>
    <List>
        <BookName>Computer Architecture</BookName>
        <Category>Computers</Category>
        <Price>125.60</Price>
    </List>
    <List>
        <BookName>Advanced Composite Materials</BookName>
        <Category>Science</Category>
        <Price>172.56</Price>
    </List>
    <List>
        <BookName>Asp.Net 4 Blue Book</BookName>
        <Category>Programming</Category>
        <Price>56.00</Price>
    </List>
    <List>
        <BookName>Stategies Unplugged</BookName>
        <Category>Science</Category>
        <Price>99.99</Price>
    </List>
    <List>
        <BookName>Teaching Science</BookName>
        <Category>Science</Category>
        <Price>164.10</Price>
    </List>
    <List>
        <BookName>Challenging Times</BookName>
        <Category>Business</Category>
        <Price>150.70</Price>
    </List>
    <List>
        <BookName>Circuit Bending</BookName>
        <Category>Science</Category>
        <Price>112.00</Price>
    </List>
    <List>
        <BookName>Popular Science</BookName>
        <Category>Science</Category>
        <Price>210.40</Price>
    </List>
    <List>
        <BookName>ADOBE Premiere</BookName>
        <Category>Computers</Category>
        <Price>62.20</Price>
    </List>
</Library>


Wednesday, July 2, 2014

List Of Mysql Queries Used any Programming Language

Following  Mysql Queries  Used In Php

  • mysql_query
  • mysql_fetch_array
  • mysql_fetch_assocs
  • mysql_fetch_row
  • mysql_fetch_object
  • mysql_close
  • mysql_fetch_field
  • mysql_fetch_leanth
  • mysql_fetch_affected_rows
  • mysql_connect
  • mysql_pconnect
  • mysql_select_db
  • mysql_create_db
  • mysql_data_seek
  • mysql_db_name
  • mysql_db_query
  • mysql_drop_db
  • mysql_error
  • mysql_field_flags
  • mysql_field_len
  • mysql_field_table
  • mysql_field_type
  • mysql_field_seek
  • mysql_free_result
  • mysql_insert_id
  • mysql_first_dbs
  • mysql_list_field
  • mysql_ping
  • mysql_hum_field
  • mysql_read_escape 
Please click here more Info

Sunday, June 15, 2014

HTML5 Video & Audio Player

Video add in webpage (Html) . below code below version html 5.



<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="src" value="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1&" />
<param name="allowfullscreen" value="true" />
<embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1&" allowscriptaccess="always" allowfullscreen="true">
</embed>
</object>

Also some above  problem , And as you know, you need Flash for this. Or it is often delivered via JavaScript as well so it is not perfect.

The HTML 5 way Nice, clean, minimal code:

<video width="640"  height="360"  poster="http://video-js.zencoder.com/oceans-clip.png"  controls preload>
 <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
 <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
 <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
  </video>

<p> Try this page in a modern browser! Or you can <a  href="http://video-js.zencoder.com/oceans-clip.mp4">download the  video</a> instead.</p>
  Solution

   
HTML5 Video & Audio Player-  no video with support format or mime type found?  in firefox
Please Create .htaccess files root folder and put here below code

AddType video/mp4  mp4 m4v
AddType audio/mp4  m4a
AddType video/ogg  ogv
AddType audio/ogg  ogg oga
AddType video/webm webm



The <video> element has several special attributes that can change or enhance its default behavior.
autoplay* Tells the browser to immediately start downloading the video and play it as soon as it can. Note that mobile browsers generally do not support this attribute, the user must tap the screen to begin video playback.
preload Hint to the browser about whether optimistic downloading of the video itself or its metadata is considered worthwhile.
Options are:
  • none - Hints to the browser that the user likely will not watch the video, or that minimizing unnecessary traffic is desirable.
  • metadata - Hints to the browser that the user is not expected to need the video, but that fetching its metadata (dimensions, first frame, track list, duration, and so on) is desirable.
  • auto - Hints to the browser that optimistically downloading the entire video is considered desirable.
poster Provides an image to show before the video loads
controls* Shows the default video controls (play, pause, etc)
height & width Sets the width and height of the video in CSS pixels
loop* Tells the browser to automatically loop the video
muted* Mutes the audio from the video
*indicates a binary attribute, which enables that behavior when the attribute is present, or has it's value set to anything.

Monday, June 9, 2014

On Mouse over show cover using css

Follow code very useful. mouse over the images, show cover as light color( according change color in css) and also given text link.

Download This image "googleimg.jpg
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>On Mouse over show cover using css</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style type="text/css">
.overlap { position:relative; -moz-box-sizing: border-box; box-sizing:border-box; -webkit-order-sizing:border-box; margin: 1.5px; width:22%; }

.overlap .innershadow { z-index: 50; width:100%; height:3px; position:absolute; top:0px; left:0px; -webkit-box-shadow: inset 0px 3px 0px rgba(255, 255, 255, 0.25); -moz-box-shadow: inset 0px 3px 0px rgba(255, 255, 255, 0.25); box-shadow: inset 0px 3px 0px rgba(255, 255, 255, 0.25); }

.overlap .cover    { width:100%; height:100%; position:absolute; top:0px; left:0px; background: #000; -webkit-transition: all 0.2s; -moz-transition: all 0.2s; -o-transition: all 0.2s; -ms-transition: all 0.2s; -moz-opacity:0.0; filter:alpha(opacity=0); opacity:0; -webkit-box-shadow: inset 0px 3px 0px rgba(255, 255, 255, 0.25); -moz-box-shadow: inset 0px 3px 0px rgba(255, 255, 255, 0.25); box-shadow: inset 0px 3px 0px rgba(255, 255, 255, 0.25); }

.overlap .link    { cursor:pointer; position:absolute;  left:50%; top:49%; background: rgba(0, 0, 0, 0.25) url(link.png) no-repeat; width:40px; height:40px; margin-left:-20px; -webkit-transition: all 0.15s; -moz-transition: all 0.15s; -o-transition: all 0.15s; -ms-transition: all 0.15s; -moz-opacity:0.0; filter:alpha(opacity=0); opacity:0; -webkit-border-radius: 30px; -moz-border-radius: 30px; border-radius: 30px; }

.overlap .show    { cursor:pointer;  position:absolute; right:50%; top:49%; background: rgba(0, 0, 0, 0.25) url(zoom.png) no-repeat; width:40px; height:40px; margin-right:-20px; -webkit-transition: all 0.15s; -moz-transition: all 0.15s; -o-transition: all 0.15s; -ms-transition: all 0.15s; -moz-opacity:0.0; filter:alpha(opacity=0); opacity:0; -webkit-border-radius: 30px; -moz-border-radius: 30px; border-radius: 30px; }
.overlap .itemtitle    { bottom:51%; cursor:pointer; text-transform:uppercase; position:absolute; width: 100%; text-align: center; -webkit-transition: all 0.1s; -moz-transition: all 0.1s; -o-transition: all 0.1s; -ms-transition: all 0.1s; -moz-opacity:0.0; filter:alpha(opacity=0); opacity:0; margin-left: 0px; }

.overlap .itemtitle a { color: #fff; font-weight: 800; font-size: 15px; }

.overlap .itemcategories { float: left; color: #aaa; font-weight: 400; font-size: 12px; text-transform:uppercase;  cursor:pointer; width: 100%; text-align: center; -webkit-transition: all 0.2s; -moz-transition: all 0.2s; -o-transition: all 0.2s; -ms-transition: all 0.2s; -moz-opacity:0.0; filter:alpha(opacity=0); opacity:0; margin-top: 6px; }

.overlap .itemcategories a { color: #aaa; font-weight: 400; font-size: 12px; }
.mr .overlap, .ml .overlap  { margin: 0; }
.link.notalone { left:50%; margin-left:-45px;}

.show.notalone { right:50%; margin-right:-45px;}

.overlap:hover .link, .overlap:hover .show, .overlap:hover .itemtitle, .overlap:hover .itemcategories {    -moz-opacity:1.0; filter:alpha(opacity=100); opacity:1; }
.overlap:hover .cover {    -moz-opacity:0.75; filter:alpha(opacity=75); opacity:0.75;}
.overlap .link:hover    { background: rgba(255, 255, 255, 0.1) url(link.png) no-repeat; }
.overlap .show:hover    { background: rgba(255, 255, 255, 0.1) url(zoom.png) no-repeat; }
</style>



</HEAD>

<BODY>
<div class="overlap"><div class="innershadow"></div> <img alt="" src="googleimg.jpg" width="250px" height="160px"><div class="cover"></div> <a href="https://news.google.com/"><div class="link ">Google News</div></a><h5 class="itemtitle"><a href="https://www.google.co.in/maps/preview?hl=en&source=newuser-ws">Google Map</a><span class="itemcategories"><a rel="tag" href="https://images.google.com/">Search Google Image</a></span></h5></div>
</BODY>
</HTML>

Saturday, May 31, 2014

How To Find & Replace String using Mysql Query

if you  find a string in a certain field and replace it with another string in database table. Please use below code.








syntax:
update [table_name] set [field_name] = replace([field_name],’[string_to_find]‘,’[string_to_replace]‘);
or
 UPDATE `table_name`
 SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

For Exp:
update user set name = replace(name,’Gupta’,'Mishra’);

Friday, May 30, 2014

Display Page Execution Time Using Php

Use this Small code to check the execution time of your script.

<?php
// Write this line at the top of script
$start = (float) array_sum(explode(‘ ‘,microtime()));

/*
your code here
*/

// Write these lines at the bottom of script
$end = (float) array_sum(explode(‘ ‘,microtime()));
echo sprintf(“%.4f”, ($end-$start));
?>



If you want to increase the execution time limit then use these:

1. set_time_limit(int $seconds)

(See it – will not work in Safe Mode)

2. ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes

(See it – ini_set will not work in Safe Mode)

3. Via .htaccess

php_value max_execution_time 90

4. Also set php.ini - This maximum execution time limit is set inside the php.ini file like this.
max_execution_time = 30; Maximum execution time of each script, in seconds



For Example


<!--  this  code at the top of the page -->
<?php
   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $starttime = $mtime;
;?>



<!--  this code at the bottom of the page -->
<?php
   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $endtime = $mtime;
   $totaltime = ($endtime - $starttime);
   echo "This page was created in ".$totaltime." seconds";
;?>

output
This page was created in 0.0027 seconds.

Friday, May 23, 2014

Multiple Drop Down out put one container

Following code very useful select one value of multi drop down (select) , show out put value define  container.

Js is pick this url: mootools-core-1.4.5-nocompat.js



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Multiple Drop Down out put one container</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">

<script type='text/javascript' src='mootools-core-1.4.5-nocompat.js'></script>
<script language="javascript">

function run(val) {


if(val==1)
{
document.getElementById("srt").innerHTML = document.getElementById("Ultra").value;
document.getElementsByName("Ultra2")[0].value="drop2";
document.getElementsByName("Ultra3")[0].value="drop3";
}
else if(val==2)
{
document.getElementById("srt").innerHTML = document.getElementById("Ultra2").value;
document.getElementsByName("Ultra")[0].value="drop1";
document.getElementsByName("Ultra3")[0].value="drop3";

}

else if(val==3)
{
document.getElementById("srt").innerHTML = document.getElementById("Ultra3").value;
document.getElementsByName("Ultra")[0].value="drop1";
document.getElementsByName("Ultra2")[0].value="drop2";

}
else{
document.getElementsByName("Ultra")[0].value="drop1";
document.getElementsByName("Ultra2")[0].value="drop2";
document.getElementsByName("Ultra3")[0].value="drop3";
}


}




</script>


</HEAD>

<BODY  onLoad="run()">


<table cellpadding="10" cellspacing="10" ><tr><td>
Drop1 <select id="Ultra" onchange="run(1)" name="Ultra" >  <!--Call run() function-->
     <option value="drop1">Select</option>
     <option value="1">text1</option>
     <option value="2">text2</option>
     <option value="3">text3</option>    
</select></td>
<td>
Drop2 <select id="Ultra2" onchange="run(2)" name="Ultra2" >  <!--Call run() function-->
     <option value="drop2">Select</option>
     <option value="4">text4</option>
     <option value="5">text5</option>
     <option value="6">text6</option>    
</select></td>
<td>

Drop3 <select id="Ultra3" onchange="run(3)" name="Ultra3" >  <!--Call run() function-->
     <option value="drop3">Select</option>
     <option value="7">text7</option>
     <option value="8">text8</option>
     <option value="9">text9</option>    
</select></td>
</tr></table>

<!-- main container Start -->
<div id="srt" style="padding:0 0 0 20px;">OutPut Area </div>
<!-- main container End -->

</BODY>
</HTML>

Saturday, April 26, 2014

Drop down content with onclick using javascript

This is very simple drop down code using html, javascript,css. This code opening/closing container  every drop down onclick heading.


<!DOCTYPE html>
<html>
    <head>
        <meta charset='utf-8'/>
        <title>Drop down content with onclick using javascript</title>
        <style>
            * { margin:0; padding:0; font-family:sans-serif; }

            body { width:650px; }

            .drop_h, li, h2 { margin-bottom:15px; }

            .drop_h {
                text-decoration:none;
                font-size:16px;
                display:block;
            }

            .content {
                display:none;
            }

            #improved li {
                position:relative;
                overflow:hidden;
            }
        </style>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script>
            $(document).ready(function(){
                $('#original .drop_h').click(function(e){
                    e.preventDefault();
                    $(this).closest('li').find('.content').slideToggle();
                   
                   
                   
                   
                   
                   
                   
                   
                });

                $('#improved .drop_h').click(function(e){
                    e.preventDefault();
                    $(this).closest('li').find('.content').not(':animated').slideToggle();
                });
            });
        </script>
    </head>
    <body>
        <h2>Drop Down Simple Script</h2>
        <ul id='original'>
            <li>
                <a href='#' class='drop_h'>Heading 1</a>
                <div class='content'>
                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
            <li>
                <a href='#' class='drop_h'>Heading 2</a>
                <div class='content'>
                    <p>PHP5 introduces a special function called '__autoload()' (the word 'autoload' prefixed by double underscores). This function allows you to avoid writing a long list of includes at the top of your script by defining them inside this function. So you can automatically load object files when PHP encounters a class that hasn't been defined </p>

                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
           
        </ul>
        <h2>Animated Drop Down </h2>
        <ul id='improved'>
            <li>
                <a href='#' class='drop_h'> Improved Heading 1</a>
                <div class='content'>
                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
            <li>
                <a href='#' class='drop_h'>Improved Heading 2</a>
                <div class='content'>
                    <p>PHP5 introduces a special function called '__autoload()' (the word 'autoload' prefixed by double underscores). This function allows you to avoid writing a long list of includes at the top of your script by defining them inside this function. So you can automatically load object files when PHP encounters a class that hasn't been defined </p>

                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
           
        </ul>
    </body>
</html>

Thursday, April 17, 2014

Create HTML form using Object Oriented Programming And Systems

Following code easy to understand made html form using php oops concept

<?php
/***** HTML Form Create using OOP *******/

class form {

    //Input Attributes
    public    $type;
    public    $name;
    public    $value;
    public  $text;
    public $opttext;
    //Select Methods                       
    public $optValues = array();
    public $starttag;
    public $action;
    public $method;
    /* form tag */
    function formtag() {
      if($this->starttag=='true') {
          echo "<form action='". $this->action ."' method='". $this->method ."'>";
      }    else {
          echo "</form>";
      }         
    }
               
     //Input Fields
     function input() {   

        if($this->type=='text') {
                echo $this->text."<input type='". $this->type ."' name='". $this->name ."' value='". $this->value ."'> ";                                                                  
        } else if ( $this->type=='select') {
                echo $this->text."<select name='". $this->name ."'> ";
                for($i=0; $i< count($this->optValues);$i++ ) {
                    echo "<option value='". $this->optValues[$i] ."'>". $this->optValues[$i] ." </option> ";
                }
                echo "</select>";                       
        } else if($this->type=='radio' || $this->type=='checkbox') {       
                echo $this->text."<input type='". $this->type ."' name='". $this->name ."' value='". $this->value ."'>".$this->opttext;                                                                  
        } else if($this->type=='button' || $this->type=='submit' || $this->type=='reset') {                           
                echo "<input type='". $this->type ."' name='". $this->name ."' value='". $this->value ."'> ";                                                                  
        }


else if($this->type=='textarea') {                           
                echo $this->text."<textarea wrap='virtual'  name='". $this->name ."'>". $this->value ."</textarea>";                                                                  
        }

       
       
        else {
           echo "Please enter the type";
        }               
     }//method end. 
   
    function br() {
            echo "<br />";
    }//if end                           
   
}
$formInputs = new form;
       
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<TITLE>OOPs HTML Form</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</head>
<body>
<h1>HTML Form using oops </h1>

<?php

    $formInputs->starttag='true';
    $formInputs->action ='';
    $formInputs->method ='post';   
    $formInputs->formtag();
       
    $formInputs->text  = "Name";
    $formInputs->type  = "text";
    $formInputs->name  = "";
    $formInputs->value =    "";   
    $formInputs->input();
    $formInputs->br();
   
    $formInputs->text  = "DOB";
    $formInputs->type  = "text";
    $formInputs->name  = "";
    $formInputs->value =    "";   
    $formInputs->input();
    $formInputs->br();
   
    $formInputs->text    = "Gender";
    $formInputs->type    = "radio";
    $formInputs->name    = "gender";
    $formInputs->opttext = "Male";   
    $formInputs->input();
   
   
    $formInputs->text    = "";
    $formInputs->type    = "radio";
    $formInputs->name    = "gender";
    $formInputs->opttext = "Female";   
    $formInputs->input();   
    $formInputs->br();       
   
    $formInputs->text  = "Country";
    $formInputs->type  = "select";
    $formInputs->name  = "country";   
    $formInputs->optValues[] = 'India'; $formInputs->optValues[] = 'UK'; $formInputs->optValues[] = 'usa';
    $formInputs->optValues[] = 'Srilanka'; $formInputs->optValues[] = 'Bhutan';      $formInputs->optValues[] = 'Tibet';
    $formInputs->input();
    $formInputs->br();
   



    $formInputs->text    = "Message";
    $formInputs->type    = "textarea";
    $formInputs->name    = "message";
    $formInputs->input();   
    $formInputs->br();       





    $formInputs->type  = "submit";
    $formInputs->name  = "";
    $formInputs->value = "Submit";   
    $formInputs->input();
    //$formInputs->br();
   
$formInputs->type  = "reset";
    $formInputs->name  = "";
    $formInputs->value = "Clear";   
    $formInputs->input();
    $formInputs->br();


    $formInputs->starttag='false';
    $formInputs->formtag();
?>       
</body>
</html>







 

Wednesday, April 9, 2014

Onclick changed top and bottom value using html and simple javascript

Onclick change value of two places at time using simple javascript and html. Please Use below code.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Onclick changed top and bottom value using html and simple javascript  </TITLE>

<script language="javascript">

function toggle(id) {

for(i=1;i<4;i++)
{
var obj = 'tab'+i;
var obj1 = 'tb'+i;

if(i==id)
{
document.getElementById(obj).style.display = 'block';
document.getElementById(obj1).className="selected" ;
}
else
{
document.getElementById(obj).style.display = 'none';
document.getElementById(obj1).className = '';
}
}
}

</script>





</HEAD>

<BODY>
<div style="display:block;" class="tab-heading" id="tab_head">Display tab top value 1<br></div>

<div class="tabcontainer">

<div class="shadetabs">

<div id="tb1" class="selected"><br><a style="cursor:pointer;color:#0000FF;" onClick="changeHeading(1); toggle(&#39;1&#39;); return false;" >Click tab1</a>&nbsp;and &nbsp;
<div id="tb2" class=" " ><a style="cursor:pointer;color:#0000FF;" onClick="changeHeading(2); toggle(&#39;2&#39;); return false;">Click tab2</a><br></div></div>

</div>

<script language="javascript">
function changeHeading(tab)
{
if(tab==1)
document.getElementById('tab_head').innerHTML = 'Display tab top value 1';

if(tab==2)
document.getElementById('tab_head').innerHTML = 'Display tab top value 2';

}
</script>
<!-- section display  all hotels  start here -->

<div style="display:block;" id="tab1">
<br> Display tab bottom value1
</div>


<div style="display:none;" id="tab2"><br> Display tab bottom  value 2 </div>

</div>
</BODY>
</HTML>

Wednesday, April 2, 2014

Simple Responsive Form design using html css

it is very useful code of Responsive Form design using html css. Following code use it.

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Simple Responsive Form</title>
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="author" content="Vikash Gupta">

   
<meta name="viewport" content="width=device-width; initial-scale=1.0;">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style type="text/css">
body {
    font-family: Arial, Verdana, Helvetica, sans-serif;
    font-size:16px;
    line-height:1.3em;
    color:#555555;
    font-weight:normal;
    background: url(../img/bg-body.jpg) repeat scroll left top;
}
a {color: #634e00;text-decoration:underline;}
a:hover {text-decoration:none;color: #634e00;}
p, ul, ol {font-size:0.9375em;}
h1, h2, h3, h4, h5, h6, p, ul, ol, dl {margin:0.7em 20px 0.9em 20px;}
h1, h2, h3, h4, h5, h6 {font-family: 'liberation-sans-1','liberation-sans-2', Arial, Verdana, Helvetica, sans-serif;font-weight:normal;color:#322801;line-height:1.2em;}
h1 {font-size:1.875em;color:#58471E;}
h2 {font-size:1.5em;color:#58471E;}
h3 {font-size:1.375em;}
h4 {font-size:0.9375em;}
h5 {font-size:0.9375em;}
img {
    -ms-interpolation-mode: bicubic;/*IE only*/
    max-width: 100%;
    width:auto;
    height:auto;
}




/************************************************************************************
Form styles
*************************************************************************************/
input,
textarea,
select {
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    -khtml-border-radius: 4px;
    border-radius: 4px;
    font-family: Arial, Verdana, Helvetica, sans-serif;
    font-size:15px;
    -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1) inset;
    webkit-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.1);
    -moz-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.1);
    box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.1);
    background:#f9f2e2;
}

input:focus,
textarea:focus,
select:focus {
    background:#eee1c3;
}
/* footer mailing list subscribe form*/
form#subForm input {
    padding:8px 5px;
    border: none;
    color:#20251c;
    width:95%;
}
form#subForm label {
    display:block;
    padding-bottom:0.25em;
}
form label.error  {
    display:block;
    padding-top:0.25em;
    color:#e45c37;
    clear:both;
    text-transform:uppercase;
    font-size:0.75em;
}


/* all main page form styles*/
fieldset {
    border:1px solid #ede0c0;
    margin:20px;
    padding-bottom:15px;
    -moz-border-radius: 6px;
    -webkit-border-radius: 6px;
    -khtml-border-radius: 6px;
    border-radius: 6px;
    background: #fff url(../img/bg-body.jpg) repeat scroll left top;
    color:#58471E;   
}
legend {
    padding:10px;
    margin-left:10px;
    font-size:1.375em;
    color:#58471E;
}
form ol {
    margin:0;
    overflow:hidden;
    margin-left:20px;
    margin-right:20px;
}
form ol li {
    float:left;
    display:inline;
    width:100%;
    margin-right:2.5%;
    margin-bottom:0.5em;
}
form ol li:nth-child(2n) {
    margin-right:0;
    /*margin-left:2.5%;*/
}
form ol li.longdesc {
    float:left;
    display:inline;
    width:100%;
}
form ol li.longdesc:nth-child(2n) {
    margin-left:0;
}
form ol li.longdesc input,
form ol li textarea {
    width:95%;
    margin-right:2.5%;
}

form ol li input {
    width:47.5%;
    margin-right:2.5%;
}



form ol li select {
    width:96%;
    margin-right:2.5%;
}


form ol li table {
/*padding:5px;*/
margin:10px 0 0 0;;
}



form ol label {
    display:block;
    margin-bottom:6px;
}
form ol label a {
color:#0033CC;
}



form ol li input,
textarea,
select {
    border:none;
    padding:10px 5px;
    /*background:#f1e1bf;*/
}
form ol li select#Enquiry {
    width:100%;
}
form ol li input {
    width:95%;
}
form em {
    font-style:normal;
}

form label small {
    display:block;
    font-size:13px;
    font-style:italic;
}

/* button style */
button {
    background:#f9d835; /* default background for browsers without gradient support */
    background:-webkit-gradient(linear, left top, left bottom, from(#f9d835), to(#f3961c));
    background:-moz-linear-gradient(top, #f9d835, #f3961c);
    background:-o-linear-gradient(top, #f9d835, #f3961c);
    border:none;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight:normal;
    padding:6px 12px;
    -moz-border-radius: 8em;
    -webkit-border-radius: 8em;
    -khtml-border-radius: 8em;
    border-radius: 8em;
    margin-top:15px;
}
button:hover {
    background:#f9d835;
    cursor: pointer;
}

input[type="submit"]
{
    background:#A26008; /* default background for browsers without gradient support */
    background:-webkit-gradient(linear, left top, left bottom, from(#A26008), to(#A26008));
    background:-moz-linear-gradient(top, #A26008, #A26008);
    background:-o-linear-gradient(top, #A26008, #A26008);
    border:none;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight:normal;
    padding:6px 12px;
    -moz-border-radius: 8em;
    -webkit-border-radius: 8em;
    -khtml-border-radius: 8em;
    border-radius: 8em;
    margin-top:15px;
}

input[type="reset"]
{
    background:#A26008; /* default background for browsers without gradient support */
    background:-webkit-gradient(linear, left top, left bottom, from(#A26008), to(#A26008));
    background:-moz-linear-gradient(top, #A26008, #A26008);
    background:-o-linear-gradient(top, #A26008, #A26008);
    border:none;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight:normal;
    padding:6px 12px;
    -moz-border-radius: 8em;
    -webkit-border-radius: 8em;
    -khtml-border-radius: 8em;
    border-radius: 8em;
    margin-top:15px;
}





/*form php error styles */
#formerror {
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    -khtml-border-radius: 4px;
    border-radius: 4px;
    background:#f9f0ee;
    margin:20px;
    border:1px solid #f9b3a4;
}
#formerror p {
    color:#E45C37;   
}





</style>
</head>
<body>
<h1>Simple Responsive Form</h1>

   
      <form name="form1" method="POST" action="#" id="form1" onSubmit="return validation_form();" autocomplete="off">

        <p>Please note that fields marked <em>(*)</em> must be completed to allow us to process your booking.</p>
       
        <fieldset>
        <legend>Your Requirements</legend>
              <ol>
        <li>
            <label for="Name">Name of fruits: <em>(*)</em></label>


<select id="fruits" name="fruits"  class="required">
<option value="">--Select fruits--</option>

<option value="apple">Apple</option>
<option value="apricot">Apricot</option>
<option value="banana">Banana</option>
<option value="carrot">Carrot</option>
<option value="grape">Grape</option>
<option value="mango">Mango</option>

</select>
          </li>
         
   <li>
            <label for="rooms">No. of Packets <em>(*)</em></label>
      <select   id="packets" name="packets">
      <option value="">--Select packets--</option>
<option  value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>

</select>
          </li>
  
 
         
        </ol>
        </fieldset>
       
                 <fieldset>
        <legend>Your Order Details:</legend>
        <ol>
          <li>
            <label for="Name">Full Name: <em>(*)</em></label>
            <input type="text" name="Name" id="Name" value="" class="required">
          </li>
          <li>
            <label for="Surname">Email: <em>(*)</em></label>
            <input type="text" name="Surname" id="Surname" value="" class="required">
          </li>
         
         
          <li>
            <label for="phone">Phone: <em>(*)</em></label>
            <input type="text" name="phone" id="phone" value="" class="required">
          </li>
         
           <li class="longdesc">
            <label for="address">Address:</label>
            <textarea name="address" id="address" rows="6" cols="40"></textarea>
          </li>
         
              <li class="longdesc">
            <label for="message">Comment / Suggestion:</label>
            <textarea name="message" id="message" rows="6" cols="40"></textarea>
          </li>
      
         
         
        </ol>
        </fieldset>
       <p> <input type="submit"   value="Order request"  name="submit">&nbsp;&nbsp;<input  type="reset" value="Clear " class="button_plan"  onClick="window.location.reload()"/> </p>
      </form>
      <!-- form ends -->



</body>
</html>

Friday, March 7, 2014

Back to top Scripts using html,css and javascript.

Back to top Scripts using html,css and javascript.It is  very Simple and easy use in any programming language. Easy use following code



backtotop.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Back to top Scripts</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script src="jquery.js" type="text/javascript"></script>
<!-- Back to top Scripts css & js start-->
<script  type="text/javascript"  >
$(document).ready(function(){

    // hide #back-top first
    $("#back-top").hide();
   
    // fade in #back-top
    $(function () {
        $(window).scroll(function () {
            if ($(this).scrollTop() > 50) {
                $('#back-top').fadeIn();
            } else {
                $('#back-top').fadeOut();
            }
        });

        // scroll body to 0px on click
        $('#back-top a').click(function () {
            $('body,html').animate({
                scrollTop: 0 //define value margin top to display
            }, 500);
            return false;
        });
    });

});
</script>
<style type="text/css">
/*Back to top button*/
#back-top {position:fixed; bottom:30px; right:0px;}
#back-top a {width:100px; display:block; text-align:left; font-weight:bold; font-size:15px; text-transform:uppercase; text-decoration:none; color:#61462e;/* background color transition */    -webkit-transition: 1s;-moz-transition: 1s;transition: 1s;}
#back-top a:hover {color: #61462e;}
/* arrow icon (span tag) */
#back-top span {width:50px; height:50px; display:block; margin-bottom:7px; background:url(images/top.png) #724c28 no-repeat center center;
    /* rounded corners */-webkit-border-radius:4px; -moz-border-radius:4px; border-radius:4px;/* background color transition */
    -webkit-transition:1s; -moz-transition: 1s; transition:1s; border:2px solid #4e3115;}
#back-top a:hover span {background-color:#bf7b3a;}
</style>
<!-- Back to top Scripts  css & js End-->

</HEAD>

<BODY>
<div>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition
<br><br>
<B>Back to top Scripts:</B><br>
C++, Cobol, MS-Dos batch, CSS, Forth, Fortran, FoxPro, HTML, XHTML, INI, Inno Setup, Java, JavaScript, KixStart, Object Pascal, Perl, PHP, Python, RSS, SQL, TCL/TK, Unix ShellScript, VBScript, Visual Basic, X86 assembler and other 120+ languages included as user highlighter definition


</div>
<!-- BAck to top Start -->
<p id="back-top">
<a href="#top"><span></span>Back to top</a>
</p>
<!-- BAck to top End-->
</BODY>
</HTML>


Download file jquery.js from "http://jquery.com/"

Wednesday, February 19, 2014

Database value convert to XML and json using php

Following code easy to use "Mysql /Any Database value convert to XML and json  using php" 

<?php



/* require the user_id as the parameter */
if(isset($_GET['user_id']) && intval($_GET['user_id'])) {

    /* soak in the passed variable or set our own */
    $number_of_posts = isset($_GET['num']) ? intval($_GET['num']) : 10; //10 is the default
    $format = strtolower($_GET['format']) == 'json' ? 'json' : 'xml'; //xml is the default
    $user_id = intval($_GET['user_id']); //no default

    /* connect to the database */
    $link = mysql_connect('localhost','root','') or die('Cannot connect to the DB');
    mysql_select_db('xmldb',$link) or die('Cannot select the DB');

    /* collect data the posts from the db */
    $query = "SELECT post_title, guid FROM pages";
    $result = mysql_query($query,$link) or die('Errant query:  '.$query);

    /* create one master array of the records */
    posts = array();


    //print_r($posts);
    if(mysql_num_rows($result)) {
        while($post = mysql_fetch_assoc($result)) {
            $posts[] = array('post'=>$post);
        }
    }

    /* output display as necessary format */
    if($format == 'json') {
        header('Content-type: application/json');
        echo json_encode(array('posts'=>$posts));
    }
    else {
        header('Content-type: text/xml');
        echo '<posts>';
        foreach($posts as $index => $post) {
            if(is_array($post)) {
                foreach($post as $key => $value) {
                    echo '<',$key,'>';
                    if(is_array($value)) {
                        foreach($value as $tag => $val) {
                            echo '<',$tag,'>',htmlentities($val),'</',$tag,'>';
                        }
                    }
                    echo '</',$key,'>';
                }
            }
        }
        echo '</posts>';
    }

    /* disconnect from the database */
    @mysql_close($link);

}
// XML Output given url run
//http://localhost/test/xmlcreate/xml.php?user_id=2&num=10


// Json Output given url run
//http://localhost/test/xmlcreate/xml.php?user_id=2&format=json
?>


Monday, February 17, 2014

According country display content/information in static web page

How to display currency/other text according country in static web page  using php script

Following code easy to use for According country display content/information in static web page.
Step 1. Dynamic page file name ipaddress.php
Step 2. Dynamic page and include filename "geoip.inc"
Step 3. Static webpage call to Dynamic page using iframe

//1. below code and save file name "ipaddress.php"
<?php


include("geoip.inc");

//$ip = empty($_REQUEST['ip']) ? '127.0.0.1' : $_REQUEST['ip'];
 $ip = $_SERVER['REMOTE_ADDR'];

$gi = geoip_open("GeoIP.dat", GEOIP_STANDARD);
$cu_code=strtoupper(geoip_country_code_by_addr($gi, $ip));

if($cu_code=="IN")
{
 echo "INR";
}
else if($cu_code=="US")
{
 echo "Doller";
{
else if($cu_code=="UK")
{

 echo "Pound";
}
else if($cu_code=="FR")
{
echo "Euro";
}
/////////more condition
?>

//2. below code and save file name  "geoip.inc"

<?php



define("GEOIP_COUNTRY_BEGIN", 16776960);
define("GEOIP_STATE_BEGIN_REV0", 16700000);
define("GEOIP_STATE_BEGIN_REV1", 16000000);
define("GEOIP_STANDARD", 0);
define("GEOIP_MEMORY_CACHE", 1);
define("GEOIP_SHARED_MEMORY", 2);
define("STRUCTURE_INFO_MAX_SIZE", 20);
define("DATABASE_INFO_MAX_SIZE", 100);
define("GEOIP_COUNTRY_EDITION", 106);
define("GEOIP_PROXY_EDITION", 8);
define("GEOIP_ASNUM_EDITION", 9);
define("GEOIP_NETSPEED_EDITION", 10);
define("GEOIP_REGION_EDITION_REV0", 112);
define("GEOIP_REGION_EDITION_REV1", 3);
define("GEOIP_CITY_EDITION_REV0", 111);
define("GEOIP_CITY_EDITION_REV1", 2);
define("GEOIP_ORG_EDITION", 110);
define("GEOIP_ISP_EDITION", 4);
define("SEGMENT_RECORD_LENGTH", 3);
define("STANDARD_RECORD_LENGTH", 3);
define("ORG_RECORD_LENGTH", 4);
define("MAX_RECORD_LENGTH", 4);
define("MAX_ORG_RECORD_LENGTH", 300);
define("GEOIP_SHM_KEY", 0x4f415401);
define("US_OFFSET", 1);
define("CANADA_OFFSET", 677);
define("WORLD_OFFSET", 1353);
define("FIPS_RANGE", 360);
define("GEOIP_UNKNOWN_SPEED", 0);
define("GEOIP_DIALUP_SPEED", 1);
define("GEOIP_CABLEDSL_SPEED", 2);
define("GEOIP_CORPORATE_SPEED", 3);
define("GEOIP_DOMAIN_EDITION", 11);
define("GEOIP_COUNTRY_EDITION_V6", 12);
define("GEOIP_LOCATIONA_EDITION", 13);
define("GEOIP_ACCURACYRADIUS_EDITION", 14);
define("GEOIP_CITYCOMBINED_EDITION", 15);
define("GEOIP_CITY_EDITION_REV1_V6", 30);
define("GEOIP_CITY_EDITION_REV0_V6",31);
define("GEOIP_NETSPEED_EDITION_REV1",32);
define("GEOIP_NETSPEED_EDITION_REV1_V6",33);
define("GEOIP_USERTYPE_EDITION",28);
define("GEOIP_USERTYPE_EDITION_V6",29);
define("GEOIP_ASNUM_EDITION_V6",21);
define("GEOIP_ISP_EDITION_V6",22);
define("GEOIP_ORG_EDITION_V6",23);
define("GEOIP_DOMAIN_EDITION_V6",24);

define("CITYCOMBINED_FIXED_RECORD", 7 );

class GeoIP {
    var $flags;
    var $filehandle;
    var $memory_buffer;
    var $databaseType;
    var $databaseSegments;
    var $record_length;
    var $shmid;
    var $GEOIP_COUNTRY_CODE_TO_NUMBER = array(
"" => 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5,
"AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "CW" => 10, "AO" => 11,
"AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17,
"AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23,
"BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29,
"BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35,
"BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41,
"CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47,
"CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53,
"CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59,
"DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65,
"ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71,
"FM" => 72, "FO" => 73, "FR" => 74, "SX" => 75, "GA" => 76, "GB" => 77,
"GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83,
"GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89,
"GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95,
"HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101,
"IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107,
"IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113,
"KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119,
"KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125,
"LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131,
"LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137,
"MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143,
"MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149,
"MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155,
"NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161,
"NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167,
"PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173,
"PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179,
"PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185,
"RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191,
"SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197,
"SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203,
"SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209,
"TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215,
"TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221,
"UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227,
"VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
"VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
"ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
"O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
"MF" => 252, "BQ" => 253,
);
    var $GEOIP_COUNTRY_CODES = array(
     "","AP","EU","AD","AE","AF","AG","AI","AL","AM","CW",
    "AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB",
    "BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO",
    "BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD",
    "CF","CG","CH","CI","CK","CL","CM","CN","CO","CR",
    "CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO",
    "DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ",
    "FK","FM","FO","FR","SX","GA","GB","GD","GE","GF",
    "GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT",
    "GU","GW","GY","HK","HM","HN","HR","HT","HU","ID",
    "IE","IL","IN","IO","IQ","IR","IS","IT","JM","JO",
    "JP","KE","KG","KH","KI","KM","KN","KP","KR","KW",
    "KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT",
    "LU","LV","LY","MA","MC","MD","MG","MH","MK","ML",
    "MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV",
    "MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI",
    "NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF",
    "PG","PH","PK","PL","PM","PN","PR","PS","PT","PW",
    "PY","QA","RE","RO","RU","RW","SA","SB","SC","SD",
    "SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO",
    "SR","ST","SV","SY","SZ","TC","TD","TF","TG","TH",
    "TJ","TK","TM","TN","TO","TL","TR","TT","TV","TW",
    "TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE",
    "VG","VI","VN","VU","WF","WS","YE","YT","RS","ZA",
    "ZM","ME","ZW","A1","A2","O1","AX","GG","IM","JE",
  "BL","MF", "BQ");
    var $GEOIP_COUNTRY_CODES3 = array(
      "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","CUW",
    "AGO","ATA","ARG","ASM","AUT","AUS","ABW","AZE","BIH","BRB",
    "BGD","BEL","BFA","BGR","BHR","BDI","BEN","BMU","BRN","BOL",
    "BRA","BHS","BTN","BVT","BWA","BLR","BLZ","CAN","CCK","COD",
    "CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI",
    "CUB","CPV","CXR","CYP","CZE","DEU","DJI","DNK","DMA","DOM",
    "DZA","ECU","EST","EGY","ESH","ERI","ESP","ETH","FIN","FJI",
    "FLK","FSM","FRO","FRA","SXM","GAB","GBR","GRD","GEO","GUF",
    "GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","SGS","GTM",
    "GUM","GNB","GUY","HKG","HMD","HND","HRV","HTI","HUN","IDN",
    "IRL","ISR","IND","IOT","IRQ","IRN","ISL","ITA","JAM","JOR",
    "JPN","KEN","KGZ","KHM","KIR","COM","KNA","PRK","KOR","KWT",
    "CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
    "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI",
    "MMR","MNG","MAC","MNP","MTQ","MRT","MSR","MLT","MUS","MDV",
    "MWI","MEX","MYS","MOZ","NAM","NCL","NER","NFK","NGA","NIC",
    "NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER","PYF",
    "PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW",
    "PRY","QAT","REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN",
    "SWE","SGP","SHN","SVN","SJM","SVK","SLE","SMR","SEN","SOM",
    "SUR","STP","SLV","SYR","SWZ","TCA","TCD","ATF","TGO","THA",
    "TJK","TKL","TKM","TUN","TON","TLS","TUR","TTO","TUV","TWN",
    "TZA","UKR","UGA","UMI","USA","URY","UZB","VAT","VCT","VEN",
    "VGB","VIR","VNM","VUT","WLF","WSM","YEM","MYT","SRB","ZAF",
    "ZMB","MNE","ZWE","A1","A2","O1","ALA","GGY","IMN","JEY",
  "BLM","MAF", "BES"
  );
    var $GEOIP_COUNTRY_NAMES = array(
    "","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Curacao",
    "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados",
    "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia",
    "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the",
    "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica",
    "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic",
    "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji",
    "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","Sint Maarten (Dutch part)","Gabon","United Kingdom","Grenada","Georgia","French Guiana",
    "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala",
    "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia",
    "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan",
    "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait",
    "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania",
    "Luxembourg","Latvia","Libya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali",
    "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives",
    "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua",
    "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia",
    "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau",
    "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan",
    "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname",
    "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand",
    "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan",
    "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela",
    "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
    "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
        "Saint Barthelemy","Saint Martin", "Bonaire, Saint Eustatius and Saba"
);

    var $GEOIP_CONTINENT_CODES = array(
  "--", "AS","EU","EU","AS","AS","NA","NA","EU","AS","NA",
        "AF","AN","SA","OC","EU","OC","NA","AS","EU","NA",
        "AS","EU","AF","EU","AS","AF","AF","NA","AS","SA",
        "SA","NA","AS","AN","AF","EU","NA","NA","AS","AF",
        "AF","AF","EU","AF","OC","SA","AF","AS","SA","NA",
        "NA","AF","AS","AS","EU","EU","AF","EU","NA","NA",
        "AF","SA","EU","AF","AF","AF","EU","AF","EU","OC",
        "SA","OC","EU","EU","NA","AF","EU","NA","AS","SA",
        "AF","EU","NA","AF","AF","NA","AF","EU","AN","NA",
        "OC","AF","SA","AS","AN","NA","EU","NA","EU","AS",
        "EU","AS","AS","AS","AS","AS","EU","EU","NA","AS",
        "AS","AF","AS","AS","OC","AF","NA","AS","AS","AS",
        "NA","AS","AS","AS","NA","EU","AS","AF","AF","EU",
        "EU","EU","AF","AF","EU","EU","AF","OC","EU","AF",
        "AS","AS","AS","OC","NA","AF","NA","EU","AF","AS",
        "AF","NA","AS","AF","AF","OC","AF","OC","AF","NA",
        "EU","EU","AS","OC","OC","OC","AS","NA","SA","OC",
        "OC","AS","AS","EU","NA","OC","NA","AS","EU","OC",
        "SA","AS","AF","EU","EU","AF","AS","OC","AF","AF",
        "EU","AS","AF","EU","EU","EU","AF","EU","AF","AF",
        "SA","AF","NA","AS","AF","NA","AF","AN","AF","AS",
        "AS","OC","AS","AF","OC","AS","EU","NA","OC","AS",
        "AF","EU","AF","OC","NA","SA","AS","EU","NA","SA",
        "NA","NA","AS","OC","OC","OC","AS","AF","EU","AF",
        "AF","EU","AF","--","--","--","EU","EU","EU","EU",
        "NA","NA","NA"
);
   
}
function geoip_load_shared_mem ($file) {

  $fp = fopen($file, "rb");
  if (!$fp) {
    print "error opening $file: $php_errormsg\n";
    exit;
  }
  $s_array = fstat($fp);
  $size = $s_array['size'];
  if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
    shmop_delete ($shmid);
    shmop_close ($shmid);
  }
  $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
  shmop_write ($shmid, fread($fp, $size), 0);
  shmop_close ($shmid);
}

function _setup_segments($gi){
  $gi->databaseType = GEOIP_COUNTRY_EDITION;
  $gi->record_length = STANDARD_RECORD_LENGTH;
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
    $offset = @shmop_size ($gi->shmid) - 3;
    for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
        $delim = @shmop_read ($gi->shmid, $offset, 3);
        $offset += 3;
        if ($delim == (chr(255).chr(255).chr(255))) {
            $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
            $offset++;

            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
                $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
                $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
        } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
                     ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
                    || ($gi->databaseType == GEOIP_ORG_EDITION)
                    || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
                    || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
                    || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
            || ($gi->databaseType == GEOIP_ISP_EDITION)
            || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
                  || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
            || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)
            || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
            || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
            || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
            || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
                    || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)                   
                    || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)                   
            || ($gi->databaseType == GEOIP_ASNUM_EDITION)
            || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
                $gi->databaseSegments = 0;
                $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
                    $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
                }
                if (($gi->databaseType == GEOIP_ORG_EDITION)
                    || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
                        || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
                        || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
            || ($gi->databaseType == GEOIP_ISP_EDITION)
            || ($gi->databaseType == GEOIP_ISP_EDITION_V6)) {
                    $gi->record_length = ORG_RECORD_LENGTH;
                }
            }
            break;
        } else {
            $offset -= 4;
        }
    }
    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
        ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
        ($gi->databaseType == GEOIP_PROXY_EDITION)||
        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
        $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
    }
  } else {
    $filepos = ftell($gi->filehandle);
    fseek($gi->filehandle, -3, SEEK_END);
    for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
        $delim = fread($gi->filehandle,3);
        if ($delim == (chr(255).chr(255).chr(255))){
        $gi->databaseType = ord(fread($gi->filehandle,1));
        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
            $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
        }
        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
        $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
                }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)
                    || ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
                    || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
                    || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
                    || ($gi->databaseType == GEOIP_ORG_EDITION)
                    || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
            || ($gi->databaseType == GEOIP_ISP_EDITION)
                    || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
                    || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
            || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
            || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
            || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
                    || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
            || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
                    || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)                   
                    || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)                   
                || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
            || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)   
                    || ($gi->databaseType == GEOIP_ASNUM_EDITION)
                    || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
            $gi->databaseSegments = 0;
            $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
            $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
            }
        if (   ( $gi->databaseType == GEOIP_ORG_EDITION )
                || ( $gi->databaseType == GEOIP_DOMAIN_EDITION )
                || ( $gi->databaseType == GEOIP_ISP_EDITION )
                || ( $gi->databaseType == GEOIP_ORG_EDITION_V6 )
                || ( $gi->databaseType == GEOIP_DOMAIN_EDITION_V6 )
                || ( $gi->databaseType == GEOIP_ISP_EDITION_V6 )) {
        $gi->record_length = ORG_RECORD_LENGTH;
            }
        }
        break;
        } else {
        fseek($gi->filehandle, -4, SEEK_CUR);
        }
    }
    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
        ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
        ($gi->databaseType == GEOIP_PROXY_EDITION)||
        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
    }
    fseek($gi->filehandle,$filepos,SEEK_SET);
  }
  return $gi;
}

function geoip_open($filename, $flags) {
  $gi = new GeoIP;
  $gi->flags = $flags;
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
    $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
    } else {
    $gi->filehandle = fopen($filename,"rb") or die( "Can not open $filename\n" );
    if ($gi->flags & GEOIP_MEMORY_CACHE) {
        $s_array = fstat($gi->filehandle);
        $gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
    }
  }

  $gi = _setup_segments($gi);
  return $gi;
}

function geoip_close($gi) {
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
    return true;
  }

  return fclose($gi->filehandle);
}

function geoip_country_id_by_name_v6($gi, $name) {
  $rec = dns_get_record($name, DNS_AAAA);
  if ( !$rec ) {
    return false;
  }
  $addr = $rec[0]["ipv6"];
  if (!$addr || $addr == $name) {
    return false;
  }
  return geoip_country_id_by_addr_v6($gi, $addr);
}

function geoip_country_id_by_name($gi, $name) {
  $addr = gethostbyname($name);
  if (!$addr || $addr == $name) {
    return false;
  }
  return geoip_country_id_by_addr($gi, $addr);
}

function geoip_country_code_by_name_v6($gi, $name) {
  $country_id = geoip_country_id_by_name_v6($gi,$name);
  if ($country_id !== false) {
        return $gi->GEOIP_COUNTRY_CODES[$country_id];
  }
  return false;
}

function geoip_country_code_by_name($gi, $name) {
  $country_id = geoip_country_id_by_name($gi,$name);
  if ($country_id !== false) {
        return $gi->GEOIP_COUNTRY_CODES[$country_id];
  }
  return false;
}

function geoip_country_name_by_name_v6($gi, $name) {
  $country_id = geoip_country_id_by_name_v6($gi,$name);
  if ($country_id !== false) {
        return $gi->GEOIP_COUNTRY_NAMES[$country_id];
  }
  return false;
}

function geoip_country_name_by_name($gi, $name) {
  $country_id = geoip_country_id_by_name($gi,$name);
  if ($country_id !== false) {
        return $gi->GEOIP_COUNTRY_NAMES[$country_id];
  }
  return false;
}

function geoip_country_id_by_addr_v6($gi, $addr) {
  $ipnum = inet_pton($addr);
  return _geoip_seek_country_v6($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
}

function geoip_country_id_by_addr($gi, $addr) {
  $ipnum = ip2long($addr);
  return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
}

function geoip_country_code_by_addr_v6($gi, $addr) {
    $country_id = geoip_country_id_by_addr_v6($gi,$addr);
    if ($country_id !== false) {
      return $gi->GEOIP_COUNTRY_CODES[$country_id];
    }
  return false;
}

function geoip_country_code_by_addr($gi, $addr) {
  if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
    $record = geoip_record_by_addr($gi,$addr);
    if ( $record !== false ) {
      return $record->country_code;
    }
  } else {
    $country_id = geoip_country_id_by_addr($gi,$addr);
    if ($country_id !== false) {
      return $gi->GEOIP_COUNTRY_CODES[$country_id];
    }
  }
  return false;
}

function geoip_country_name_by_addr_v6($gi, $addr) {
    $country_id = geoip_country_id_by_addr_v6($gi,$addr);
    if ($country_id !== false) {
      return $gi->GEOIP_COUNTRY_NAMES[$country_id];
    }
  return false;
}

function geoip_country_name_by_addr($gi, $addr) {
  if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
    $record = geoip_record_by_addr($gi,$addr);
    return $record->country_name;
  } else {
    $country_id = geoip_country_id_by_addr($gi,$addr);
    if ($country_id !== false) {
      return $gi->GEOIP_COUNTRY_NAMES[$country_id];
    }
  }
  return false;
}

function _geoip_seek_country_v6($gi, $ipnum) {

  # arrays from unpack start with offset 1
  # yet another php mystery. array_merge work around
  # this broken behaviour
  $v6vec = array_merge(unpack( "C16", $ipnum));

  $offset = 0;
  for ($depth = 127; $depth >= 0; --$depth) {
    if ($gi->flags & GEOIP_MEMORY_CACHE) {
      // workaround php's broken substr, strpos, etc handling with
      // mbstring.func_overload and mbstring.internal_encoding
      $enc = mb_internal_encoding();
       mb_internal_encoding('ISO-8859-1');

      $buf = substr($gi->memory_buffer,
                            2 * $gi->record_length * $offset,
                            2 * $gi->record_length);

      mb_internal_encoding($enc);
    } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
      $buf = @shmop_read ($gi->shmid,
                            2 * $gi->record_length * $offset,
                            2 * $gi->record_length );
        } else {
      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
        or die("fseek failed");
      $buf = fread($gi->filehandle, 2 * $gi->record_length);
    }
    $x = array(0,0);
    for ($i = 0; $i < 2; ++$i) {
      for ($j = 0; $j < $gi->record_length; ++$j) {
        $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
      }
    }

    $bnum = 127 - $depth;
    $idx = $bnum >> 3;
    $b_mask = 1 << ( $bnum & 7 ^ 7 );
    if (($v6vec[$idx] & $b_mask) > 0) {
      if ($x[1] >= $gi->databaseSegments) {
        return $x[1];
      }
      $offset = $x[1];
    } else {
      if ($x[0] >= $gi->databaseSegments) {
        return $x[0];
      }
      $offset = $x[0];
    }
  }
  trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
  return false;
}

function _geoip_seek_country($gi, $ipnum) {
  $offset = 0;
  for ($depth = 31; $depth >= 0; --$depth) {
    if ($gi->flags & GEOIP_MEMORY_CACHE) {
      // workaround php's broken substr, strpos, etc handling with
      // mbstring.func_overload and mbstring.internal_encoding
      $enc = mb_internal_encoding();
       mb_internal_encoding('ISO-8859-1');

      $buf = substr($gi->memory_buffer,
                            2 * $gi->record_length * $offset,
                            2 * $gi->record_length);

      mb_internal_encoding($enc);
    } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
      $buf = @shmop_read ($gi->shmid,
                            2 * $gi->record_length * $offset,
                            2 * $gi->record_length );
        } else {
      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
        or die("fseek failed");
      $buf = fread($gi->filehandle, 2 * $gi->record_length);
    }
    $x = array(0,0);
    for ($i = 0; $i < 2; ++$i) {
      for ($j = 0; $j < $gi->record_length; ++$j) {
        $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
      }
    }
    if ($ipnum & (1 << $depth)) {
      if ($x[1] >= $gi->databaseSegments) {
        return $x[1];
      }
      $offset = $x[1];
        } else {
      if ($x[0] >= $gi->databaseSegments) {
        return $x[0];
      }
      $offset = $x[0];
    }
  }
  trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
  return false;
}

function _common_get_org($gi, $seek_org){
  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
    $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
    } else {
    fseek($gi->filehandle, $record_pointer, SEEK_SET);
    $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
  }
  // workaround php's broken substr, strpos, etc handling with
  // mbstring.func_overload and mbstring.internal_encoding
  $enc = mb_internal_encoding();
  mb_internal_encoding('ISO-8859-1');
  $org_buf = substr($org_buf, 0, strpos($org_buf, "\0"));
  mb_internal_encoding($enc);
  return $org_buf;
}

function _get_org_v6($gi,$ipnum){
  $seek_org = _geoip_seek_country_v6($gi,$ipnum);
  if ($seek_org == $gi->databaseSegments) {
    return NULL;
  }
  return _common_get_org($gi, $seek_org);
}

function _get_org($gi,$ipnum){
  $seek_org = _geoip_seek_country($gi,$ipnum);
  if ($seek_org == $gi->databaseSegments) {
    return NULL;
  }
  return _common_get_org($gi, $seek_org);
}



function geoip_name_by_addr_v6 ($gi,$addr) {
  if ($addr == NULL) {
    return 0;
  }
  $ipnum = inet_pton($addr);
  return _get_org_v6($gi, $ipnum);
}

function geoip_name_by_addr ($gi,$addr) {
  if ($addr == NULL) {
    return 0;
  }
  $ipnum = ip2long($addr);
  return _get_org($gi, $ipnum);
}

function geoip_org_by_addr ($gi,$addr) {
  return geoip_name_by_addr($gi, $addr);
}

function _get_region($gi,$ipnum){
  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
    if ($seek_region >= 1000){
      $country_code = "US";
      $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
    } else {
            $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
      $region = "";
    }
  return array ($country_code,$region);
    }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
    //print $seek_region;
    if ($seek_region < US_OFFSET){
      $country_code = "";
      $region = ""; 
        } else if ($seek_region < CANADA_OFFSET) {
      $country_code = "US";
      $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
        } else if ($seek_region < WORLD_OFFSET) {
      $country_code = "CA";
      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
    } else {
            $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
      $region = "";
    }
  return array ($country_code,$region);
  }
}

function geoip_region_by_addr ($gi,$addr) {
  if ($addr == NULL) {
    return 0;
  }
  $ipnum = ip2long($addr);
  return _get_region($gi, $ipnum);
}

function getdnsattributes ($l,$ip){
  $r = new Net_DNS_Resolver();
  $r->nameservers = array("ws1.maxmind.com");
  $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
  $str = is_object($p->answer[0])?$p->answer[0]->string():'';
  $str = substr( $str, 1, -1 );
  return $str;
}

?>


//3. Static Web pages code and save file "display.html" and above file call using iframe
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> new document </title>
<meta name="generator" content="editplus">
<meta name="author" content="">
<meta name="keywords" content="">
<meta name="description" content="">
</head>

<body>
          <iframe scrolling="no"  allowtransparency="true" src="ipaddress.php" width="207" height="38" frameborder="1"  align="top" ></iframe>
</body>
</html>