PC Database

Hello all, I created a Web Based Database to run on my PC using HTML, PHP and MySQL.
The database works great. The only problem I have is that when I fill in the forms, I don’t want it to be sent out as an Email instead, I want it to print onto my local printer in a landscape mode.

What or where can I find codes to do this?

Thanks in advance.

Well, there are many ways to do that. Are you wanting a print button on the page? You could create a doc or pdf and then print that. But, if you want to use a DIV and place things into it you want to print, you can use something like this. ( I found it on StackOverflow… )

<div id="divToPrint" style="display:none;">
  <div style="width:200px;height:300px;background-color:teal;">
           <?php echo $html; ?>      
  <input type="button" value="print" onclick="PrintDiv();" />

 <script type="text/javascript">     
    function PrintDiv() {    
       var divToPrint = document.getElementById('divToPrint');
       var popupWin = window.open('', '_blank', 'width=300,height=300');
       popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');

This will create a popup of a DIV and you can print it. This is NOT a working model, just and example to get you started. There are other ways to print it, too. You can just use CSS if you want. But, you would need to open another page with CSS that auto-prints it. This seems to be easy enough…

Also, to explain a little further… Printing is CLIENT-SIDE. PHP is SERVER-SIDE. The printing must be done in the client since PHP does not have access to the browser! So, this is probably the best way.

Thank you ErnieAlex, This answers my question. Your help is greatly appreciated.

Glad I could help! See you in your next programming puzzle…

Sponsor our Newsletter | Privacy Policy | Terms of Service