PHP - How to creat print botton - Asked By Olusegun A. on 07-Aug-10 01:08 PM

Hello friends,

I want to create a print button on my page where by the visitor can print the page. pls what is the syntax?

regards,
adsegzy
Super Man replied to Olusegun A. on 07-Aug-10 01:25 PM
YOU CAN USE THIS CODE ON CLICK OF BUTTON
<?php
function printthispage()
{
  $fhandle = fopen("test2.php","rb");
  $contents = fread($fhandle, filesize("test2.php"));
  $output = eval($contents);
  $handle = printer_open("Dell Laser Printer M5200");
  printer_set_option($handle,PRINTER_MODE,"raw");
  printer_write($handle,$output);
  printer_close($handle);
}
?>


But better to use javascript :

use this :

<A HREF="javascript:window.print()">Click to Print This Page</A>

Olusegun A. replied to Super Man on 07-Aug-10 01:33 PM

Thanks Khan for your quick responce