Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2003-05-25, 05:22 AM
Junior Member
 
Join Date: May 2003
Posts: 1
chuckz
Default

Using PHP and MySQL, how difficult would it be to generate and print reports using the MySQL data? I would like to generate reports similar to a spreadsheet with headers and columns etc. Could I accomplish this with PHP? Are there scripts or examples I could look at?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2003-05-26, 05:16 AM
Junior Member
 
Join Date: Mar 2003
Location: UT
Posts: 16
wjensen
Default

That depends on what exactly it is you're trying to do. You can just write a standard PHP script that is accessed through a web browser and use your browser's print feature. One problem with this method is that it is difficult to predict where page breaks will be, since there is no page break in HTML.

If you're running on a Windows system with PHP >=4.0.4 you can use the printer library.

Code:
<?
$handle = printer_open();
printer_write($handle, "Text to print");
printer_close($handle);
?>
The downside to this method is that it might get complicated if you're printing anything but plain text. I don't really know because I've never tried.

If you're on a Unix/Linux/etc. system you can write the data to a file and use

Code:
<?
system("lp $filename");
?>
I'm a Linux newbie, so I don't know a lot about other ways of doing this in Linux. I know you can do it with postscript somehow.

If you're on a Windows system with MS Office and want to use HTML to format the output, but still want the process automated (and don't mind not having page breaks), try this:

Code:
<?
system("C:\Program Files\Microsoft Office\Office10\msohtmed.exe /p $filename");
?>
You would still have to write your output to a file first.

For more details check out www.php.net/printer
__________________
Wayne Jensen
Reply With Quote
  #3 (permalink)  
Old 2003-05-28, 06:27 PM
Member
 
Join Date: May 2003
Posts: 47
barand
Default

Another option if want to use php to generate the reports is to write a pdf file.

FPDF is free and easy to use. The site has samples.

You could also consider a reporting package like Crystal which would connect directly to your mysql db to create reports.
__________________
Barand
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:40 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.