Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

How can i print the contents of a div along with its styling ?

I am making a small website which sells products online.

The customers whose payment is confirmed they are provided with an invoice online. I want a functionality that when he clicks on print button only invoice along with its styling gets printed.

Also there can be multiple invoices on a single page.

I want to print each invoice separately.

2 Answers

I don't know exactly what you're asking, but maybe @media print is something for you?

http://www.w3schools.com/css/css_mediatypes.asp

If I understand clearly what you want I would simply do that.

<div class="content">

   <p class="styles">

          <?php  echo "your content in php here"; ?>

          // or maybe you could display your content if this one is put previously inside an associative array.

         <?php echo NameOfArray["content"];?>  

  </p>

</div>

Let me explain myself more clearly.

I am making a small website which sells products online.

The customers whose payment is confirmed they are provided with an invoice online. I want a functionality that when he clicks on print button only invoice along with its styling gets printed.

Also there can be multiple invoices on a single page.

I want to print each invoice separately.