Print selected webpage data using Javascript

Many times we would like to place a button on webpage to print the content of that web page via an actual printer. JavaScript helps you to implement this functionality using the print function of window object.

The JavaScript print function window.print() prints the current web page when executed. You can call this function directly using the onclick event and also set which portion would be printed.

See the Example as below :

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript">
            function printthis() {
                var printthis = document.getElementById('printthis');
                var popupWin = window.open('', '_blank', 'width=1000,height=600');
                popupWin.document.open();
                popupWin.document.write('<html><body onload="window.print()">' + printthis.innerHTML + '</html>');
                popupWin.document.close();
            }
        </script>
    </head>
    <body>
        <div>
            Other contents
        </div>
        
        <div id="printthis">
            <div>
                Print this portion
            </div>
        </div>
        <div>
            <input type="button" value="print" onclick="printthis();" />
        </div>
    </body>
</html>

 

sometimes we want some portion of the page need to be print not a whole page,as per above example set id or class to portion which need to print (here #printthis).
when javascript function call on onclick then this function prints part of page which having data within #printthis div.

How to Get Address From mySQL via PHP in Google Map

this is a simple tutorial how we get address from database and then view the address location using google map.
first create a company company

CREATE  TABLE  `address` (
`id` INT NOT  NULL  AUTO_INCREMENT  PRIMARY  KEY ,
 `company_name` VARCHAR( 100  )  NOT  NULL ,
 `address` VARCHAR( 255  )  NOT  NULL ,
 `city` VARCHAR( 100  )  NOT  NULL
) ENGINE  =  MYISAM ;

let’s insert some data Continue reading “How to Get Address From mySQL via PHP in Google Map”