views:

699

answers:

3

Hello,

I have a report say,

Sno Address Name Age

when users click on Print button, they should be able to print the respective report

Can anyone help me how can i handle this in php, as i generate this report in php

I get all the info from table(MySql)

Thanks for the help

+1  A: 

This is a function of the browser, not any server-side code. However, you can provide a button (which you code in the HTML output) which will print the page when clicked. Incidentally, depending on the browser configuration, it may also print the button.

<input type="button" onClick="window.print()" value="Print The Report"/>
Ron Gejman
window.print() -> will print the whole page rightLets say my webpage is a 2 column layout and and in the second column i'm generating the reportIs there a way i give print, only the desired layoout
luvboy
+1  A: 

I would not call this a PHP issue per se, as the solution is very easy through the use of some CSS rules.

http://www.w3.org/TR/CSS2/media.html

That should contain all you need to know, specifically the "print" media type. :)

Edit: This should have been a response to the comment above where the issue was clarified a bit.

grimman
+2  A: 

CSS Printing can be pretty good, but isn't the most reliable. An alternative is to look at generating PDF files from PHP. Take a look at the FPDF library

nickf
Thanq, ur answer gave me an clueI'm generating the Excel/PDF docs and users can take prints from those docsThanx a lot
luvboy