O'Reilly logo

Web Database Applications with PHP and MySQL, 2nd Edition by David Lane, Hugh E. Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 13. Reporting

In many web database applications, you'll want to produce printable paper reports. For example, you might want to produce a stock report from an online store, a customer receipt, a printable version of an HTML page, or a fill-in form to be faxed. Unfortunately, this isn't easy: PHP doesn't have great built-in tools for reporting that are portable across all platforms. Because of this, reporting is one of the more difficult tasks in PHP.

This chapter shows you how to produce reports using PHP. We show you how to use R&OS Ltd.'s excellent pdf-php library to produce PDF (Adobe Portable Document Format) files that can be downloaded, saved, and printed by your users. PDF is now the most common format for providing reports on the Web, and the pdf-php library allows you to produce complex, configurable reports, and to include graphics and images. It's similar to a PEAR package, and we include a detailed discussion of almost all of its methods.

We don't discuss other reporting schemes for PHP, but we do discuss how to find out more about them in the next section.

Creating a Report

After you've decided you need to produce printable output, the next step is to decide what format to produce it and what tools to use to create it. As Andrew Tanenbaum said in his classic quote from the first edition of his book, Computer Networks, "The nice thing about standards is that you have so many to choose from; furthermore, if you do not like any of them, you can just wait for next year's ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required