Jump to content

printing number of rows per page to a printer


fohanlon

Recommended Posts

Hi Guys

 

Could anyone tell me how to go about the following - do I use css print style sheet or php.

 

I am using php and mysql to pull out and display records onto a webpage.  I have an option view all records that lists all records in the table.  I also have an option print all records.  However, my issue is when I go to print on some pages the information is split for example half the image on the bottom of the page and the other half on the top of the new page.

 

is there any techniques to force say 5 rows per page and then force a new page on the printer and print 5 more etc. 

 

I was going down the create pdf route but the file is large and user is left waiting for file to be generated.

 

Many thanks,

 

Fergal.

 

Link to comment
Share on other sites

You can refer PHP Printer_functions, I think it can be done like this

 

<?php
$handle = printer_open();
// you can fetch data and store in a variable then print 
printer_write($handle, "Text to print"); // keeping it here 
// and after 5 records prints then you can close 
printer_close($handle);
?>

 

Windows users must enable php_printer.dll inside of php.ini in order to use these functions.
Link to comment
Share on other sites

well printing a page is always an issue in web design as the transition from server -> browser -> Printer is never the same.  The best way is the pdf as you described as it removes all browser headings and you get a universal print, the print software in php won't get you anywhere as this is for internal printing on a server like a log file being printed every X days via a cron, it can't force print on a client.  I'd say pdf unless you want to fight the css to make it perfect, as for the five rows per page that is again a styling thing use a modular

 

<?php
$i = 0
while($row = mysqlfetch){
if($i%5 = 0){//New page}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.