-1

I have a website which consists of 5 pages. I have created a special page called print_page.php which contains the contents of all 5 pages.

How can I add a link at the top of the 5 individual pages which when pressed will print the contents of the print_page.php?

Thanks for any help

Elliot
  • 257
  • 7
  • 15
  • You could link to 'print_page.php' and then with JavaScript print the page and go back to previous page but that is an ugly solution. – putvande Oct 14 '13 at 13:33
  • Or you could include your 'print_page.php' in your current page and use CSS to hide it and show it on print. – putvande Oct 14 '13 at 13:43

3 Answers3

0

Are you sure you need that separate page?

First opportunity -- include that print_page.php to a div, that is visible only on print:

<div class="print_only"><?php include('print_page.php'); ?></div>

CSS:

@media screen {
.print_only { display: none; }
}

@media print {
.print_only { display: block; }
}

Then print it with window.print();

Second opportunity is to re-design your site to have relevant printable content on all pages designed with @media appropriately.

Cyrill
  • 21
  • 2
-1

You can define every page as a block in print_page.php. So, when you are on page1, print page url will contain something like

 <a href="print_page.php?id=firstpage".

Then you show content depending on id variable.

Yax
  • 11
  • 2
  • Not sure if your following or I don't understand. I don't want the user to see print_page.php. I just want the contents of this page to print when they press the print button on any of the 5 pages? – Elliot Oct 14 '13 at 13:33
  • I've made edit but it's not visible. Make hidden div (display: none) and print only the content that div contains. http://stackoverflow.com/questions/2255291/print-the-contents-of-a-div – Yax Oct 14 '13 at 13:54
-1

I think you would need to use javascript to accomplish this.

<a href="print_page.php" onClick ="window.print();return false">
user2879041
  • 1,077
  • 1
  • 12
  • 25