Specifications

This is a long-ish script, but can be easily adapted to suit your needs, or to auto-generate polls
via an interface. One important feature that this script is missing is any sort of anti-cheating
mechanism. Users would quickly discover that they can vote repeatedly and make the result
meaningless.
You can use a similar approach to draw line graphs, and even pie charts, if you are good at
mathematics.
Other Image Functions
In addition to the image functions we have used in this chapter, there are functions to let you
draw curved lines (ImageArc()) and polygons (ImagePolygon()), as well as variations on the
ones we have used here. Always begin by sketching what you want to draw, and then you can
hit the manual for any extra functions you might need.
Further Reading
A lot of reading material is available online. If youre having trouble with the image functions,
it sometimes helps to look at the source documentation for gd because the PHP functions are
wrappers for this library. The gd documentation is available at
http://www.boutell.com/gd/
There are also some excellent tutorials on particular types of graph applications, particularly at
Zend and Devshed:
http://www.zend.com
http://devshed.com
The bar chart application in this chapter was inspired by the dynamic bar graph script written
by Steve Maranda, available from Devshed.
Next
In the next chapter, well tackle PHPs handy session control functionality, new in PHP 4.
Advanced PHP Techniques
P
ART IV
428
24 7842 CH19 3/6/01 3:42 PM Page 428