Print a div contents in Php

If You want to print the section or Div contents, then please do the following…

By using the following code you can print the contents in a div or section.

 

Html  Section:

// The Printing button. On click this button the print preview opens


<div class="row">
      <div class="col-md-12"> 
              <button class="xshr_print_section_btn" onclick="javascript:printDivContents('xshr_print_section')">Print Details</button></div>
</div>

<!-- html Ends -->

Script Section:

<!-- For Print the Contents Starts -->

<script language="javascript" type="text/javascript">

function printDivContents(divID) {

//Get the HTML of div
var divElements = document.getElementById(divID).innerHTML;

//Get the HTML of whole page
var oldPage = document.body.innerHTML;

//Reset the page's HTML with div's HTML only
document.body.innerHTML = 
"<html><head><title></title></head><body>" + 
divElements + "</body>";

//Print Page
window.print();

//Restore orignal HTML
document.body.innerHTML = oldPage;


}
</script>

<!-- For Print the Contents / Ends-->

 

 

also solution available at: how to print a Div content in javascript

How to Print Last Executed Query in CakePhp?

How to Print Last Executed Query in CakePhp?

 

Here, ModelName is the Query from Model Name

$dbo = $this->ModelName->getDatasource();
$logs = $dbo->getLog();
$log = end($logs['log']);


echo "<pre>"; print_r($log); echo "</pre>"; 
exit();

 

# The Output will come like this….

 

Array
(
    [query] => SELECT * FROM .......
    [params] => Array
                (
                )

    [affected] => 0
    [numRows] => 0
    [took] => 3
)

 

How to Update the Current Browser URL

# UPDATE THE CURRENT URL IN BROWSER::
<script>

ChangeUrl = function(page, url) {

    if (typeof (history.pushState) != "undefined") {

        var obj = { Page: page, Url: url };

        history.pushState(obj, obj.Page, obj.Url);

        $('.breadcrumb-get-a-pro').attr('href', url);

    } else {

        alert("Browser does not support HTML5.");

    }

}

</script>