Reputation: 3389
I am building an order system for a client and would like to give them the ability to print all invoices but i have no idea how to do it
the invoices will be stored in a mysql db and I would like display each invoice in a fresh page EG invoice.php?ID=234
but is it possible to print an array of pages?
I'm really stuck with this one so any ideas would be much appreciated.
Thanks for reading.
Im talking about printing to paper, through an actual printer.
Upvotes: 0
Views: 4126
Reputation: 12870
There's a couple of ways you could do this:
1) Print a summary. Ok, maybe it's just me, but I HATE paper. I'd rather just have a table output of the important information and sent to the printer via Javascript.
2) Build a summary page in a loop, adding a CSS page break and then javascript-ing to the printer
3) Build a multi-page PDF.
My method for forcing user to printer: Open page in new window via action=_blank
, then including this: <body onload="self.print()">
Here's a method to handle pagination on printers: How to deal with page breaks when printing a large HTML table
Upvotes: 2
Reputation: 56769
You could have the content of invoice.php be generated and import into your invoice report page using the include
command:
$ID = 234;
include('invoice.php');
$ID = 235;
include('invoice.php');
$ID = 236;
include('invoice.php');
Obviously this would be a loop, not hard-coded. If there's a lot of invoices, you would probably only want to display a few at a time. Your invoice page would need to be coded to handle ID parameter from query string or variable.
invoice.php:
if (isset($_GET['ID']))
$ID = $_GET['ID'];
// use $ID for displaying invoice
Upvotes: 0