Are you new to this? That's great! Here are some suggestions for you to experiment with. This method utilizes jQuery to fetch data from the server, place it in a dynamically generated iframe, and then print it out (perfect for CI, WP, or any other platform). Is that what interests you?
1.- Working with jQuery
// <input type="button" id="print_me" data-form_id="101">
$("#print_me").live("click", function() {
var form_id = $(this).data("form_id"); // obtaining value 101
$.post(
// URL of the server where data is retrieved for printing
window.location.href,
{
// variables sent to the server to retrieve data for printing
form_id : form_id // sending form_id=101
// etc
},
// output.contents contains the printable content
function(output) {
// creating an iframe
var ifrm = document.createElement("iframe");
ifrm.style.display = "none";
document.body.appendChild(ifrm);
setTimeout(function() {
// inserting content into the iframe
$(ifrm).contents().find("body").html(output.contents);
}, 1);
// printing when the iframe has loaded
ifrm.onload = function() {
ifrm.contentWindow.print();
}
}, 'html');
});
2.- Processing on the server side
$form_id = $_REQUEST['form_id']; // receiving data here
ob_start();
// echoing HTML formatted data to print
$contents = ob_get_contents(); // $contents holds all echoed HTML
ob_end_clean();
$output['contents'] = $contents; // wrapping it in $output
echo json_encode($output); // echoing JSON encoded data
exit; // exiting at this point is crucial!
You need to thoroughly investigate each of these steps. Once you reach your goal, you will have gained valuable knowledge. Best of luck!