Creating a Database-Driven Graph
Now that I've covered the basics of image generation with PHP, which is surprisingly easy, I'll develop a more advanced application that creates a graph derived from stored data.
The example I'll use will be based on the sports pool application developed back in Chapter 1, Advanced PHP Programming. At the time, I wrote a script that created an array of how each player was doing to date. In this section and the next, you'll create a graph for each week's results instead. In the process, you'll see how to create different shapes in your image, including rectangles, dashed lines, and circles.
There are two functions for creating rectangles: imagerectangle() and imagefilled rectangle(). The latter obviously makes ...
Get PHP Advanced for the World Wide Web: Visual QuickPro Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.