Print html table in php

I have a table in a PHP page. It is a invoice. So I want to print it after adding items to it, and I had already done the coding part and all the things are working properly.

Now I just want to print that invoice table to a paper by pressing a button. I searched on Google but no clue is found to do that.

Can any one help me?

This is my table on right hand side. It is populated by the form in left hand side so I just want to print that right hand side table:

Print html table in php

Print html table in php

asked Jul 22, 2012 at 4:40

Print html table in php

3

Try this one:

Add an attribute id to your table your_content

Place an anchor tag :

   Print 

And add script:

This script will initially show print preview of the content that is inside your table.

 

Print 

​​​​​​

You can see the demo here: http://jsfiddle.net/Pxqtb/

answered Jul 22, 2012 at 6:11

pat34515pat34515

1,93912 silver badges13 bronze badges

0

i used this code and it solved my problem. thank you all for helping me.....

function printlayout() {
     var data = '';           
       var DocumentContainer = document.getElementById('printlayout');
        //data += $('printlayoutable').html();
        //data += '';
var WindowObject = window.open('', "TrackHistoryData",
"width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
WindowObject.document.writeln(DocumentContainer.innerHTML);
//WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();

answered Jul 22, 2012 at 7:03

Print html table in php

YasithaYasitha

9012 gold badges17 silver badges41 bronze badges

You have a few options. (1) If you create a new HTML page with just the invoice, the user can print that page using the browser's print capacity. (2) Alternatively, you can allow the user to download an invoice document which you create and print that. (3) You can use the JavaScript command window.print(); in conjunction with #1. Have a look at this.

answered Jul 22, 2012 at 4:48

NickNick

5,89710 gold badges52 silver badges77 bronze badges

How to display HTML table in PHP?

First of all, Include PHP script file developers.php..
Create an HTML table using Bootsrap 4..
Check $fetchData is an array or not with if & else condition..
Then apply foreach loop to the $fetchData..
After that print the required data in the table..

How do you print a table in HTML?

The HTML Table will be printed with a Print Preview using JavaScript. The following HTML Markup consists of an HTML DIV inside which there is an HTML Table and an HTML Button. The Button has been assigned a JavaScript OnClick event handler which makes call to a JavaScript function named PrintTable.

How can I use HTML in PHP?

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the PHP. Step 2: Now, we have to place the cursor in any tag of the tag where we want to add the code of PHP. And, then we have to type the start and end tag of PHP.

How fetch data from database in PHP and display HTML table?

Use the following steps for fetch/retrieve data from database in php and display in html table:.
Step 1 – Start Apache Web Server..
Step 2 – Create PHP Project..
Step 3 – Execute SQL query to Create Table..
Step 4 – Create phpmyadmin MySQL Database Connection File..
Step 5 – Create Fetch Data PHP File From Database..