View Full Version : PHP poll with image output

03-27-2007, 12:58 AM
Hey, I'm staring a new project and i am trying to make an poll, which is fine, but what i need to do is have the results outputted into an image.

I havent been able to find anything like this on google so does anyone have any thoughts?



03-27-2007, 01:23 AM
PHP has an image library called the GD library. The PHP manual can get you started on this page here (http://us2.php.net/manual/en/ref.image.php) and this one here (http://us2.php.net/manual/en/function.imagecreate.php).

03-27-2007, 04:00 PM
The easiest way is to simply make a graphic that is the height of your percentage bars.

Then echo out the width of the image as the percentage.

foreach ($results as $result) {
echo '<img src="bar.gif" width="'.$result['percentage'].'" />';