Jump to content


This topic is now archived and is closed to further replies.


Printing In PHP

Recommended Posts


Never actually had to do this before. I have setup a script to send an email out containing some information. as such

$body = "<body bgcolor='#23972C'><font face='Verdana' size='2' color='white'>";
$body .= "Hello " . $name . ",<br><br>";
$body .= "Following is the information on one of our properties you requested.<br><br>";
$body .= "Kind Regards<br>";
$body .= "Connaught Estates<br><a href='http://www.connaughtestates.com'>http://www.connaughtestates.com</a><br><hr width = '50%' color='white' align='left' height='1px'><br><b>" . $title . "</b><br>";
$body .= $image . "<br><b>£" . $price . " " . $type . "<font color='black'> " . $status . "</font>";
$body .= "<br><br>Address: </b>" . $address . "<br><b>Area: </b>" . $area;
$body .= "<br><br><b>Rental/Purchase: </b>" . $rentalorpurchase;

if ($rentalperiod != "") {
$body .= "<br><b>Rental Period: </b>" . $rentalperiod;

$body .= "<br><b>Bedrooms: </b>" . $bedrooms . "<br><b>Bathrooms: </b>" . $bathrooms;
$body .= "<br><br>" . $fulldescription;
$body .= "</font></body>";

How would i get PHP to actually print this (to  a printer) so that it prints the information and not the code itself?

Share this post

Link to post
Share on other sites
you can't - the only thing you coudl do is use the javascript window.print(); command on the onload event of the body. This would need the users email agent to support js. Same could be done on a normal web page - BUT I would be very annoyed at something trying to print automatically without my input. I don't want to see warnings that I have tried to print when my printer is off - or that I have been charged 5p for printing something I didn't request when I am using a cluster and have to pay for printing....

I just don't want anything to print out automatically - I want control and that is teh case for the vast majority of users on the web.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.