Comments for Displaying a percentage bar using PHP
14 comments for this article.
Subscribe to the comments for this article
Posted: 2007-08-04 21:20:06 by phper
Very nice. Thank you very much.
Posted: 2007-12-10 23:08:16 by Chathura
Hi!
I'm trying to use your graph on my web site. but it doesn't work. GD also installed. everything in perfect.
http://www.efm.lk/test
php info: http://www.efm.lk/test/info.php
I'm trying to use your graph on my web site. but it doesn't work. GD also installed. everything in perfect.
http://www.efm.lk/test
php info: http://www.efm.lk/test/info.php
Posted: 2007-12-10 23:13:19 by lobo235 - Netlobo Staff Member
I had a look at http://efm.lk/test/graph.php?per=76.82 which is what generates the image and you can see there is a PHP warning on the page. It is very important that the graph.php page does not have any whitespace before the first opening PHP tag or any statements that send output to the browser since the page is outputting an image. Please make sure you don't have any echo statements and that there is no whitespace outside of the <?php ?> tags.
Posted: 2008-08-28 08:12:35 by Andy
Your missing the ; after the varible in the image link it should be:
<img src="/media/examples/graph.php?per=76.82;" alt="76.82% graph" />
<img src="/media/examples/graph.php?per=76.82;" alt="76.82% graph" />
Posted: 2008-08-28 08:14:36 by lobo235 - Netlobo Staff Member
You shouldn't need a semi-colon after the 'per' parameter in the URL. Were you not able to get it to work without the semi-colon?
Posted: 2008-08-29 07:39:40 by Andy
Yeah could'nt get it to work at all without the semi-colon.
Posted: 2009-01-07 09:31:32 by Matt
I can not get the graph to work. I copied it exactly from the site
and when I try it I get...
The image “http://acri/it/tasks_list/graph.php?per=67.89” cannot be displayed, because it contains errors.
Why could this be? I have GD running and all.
and when I try it I get...
The image “http://acri/it/tasks_list/graph.php?per=67.89” cannot be displayed, because it contains errors.
Why could this be? I have GD running and all.
Posted: 2009-01-07 09:35:01 by lobo235 - Netlobo Staff Member
Matt,
If you save the image to your computer and open it up in a text editor you will most likely see an error message that will help you diagnose the problem.
If you don't see an error when you open the image in a text editor then you probably have display_errors set to 'Off' in your php.ini. If that's the case then set display_errors to 'On' and save the image again so you can see the error message.
lobo235
If you save the image to your computer and open it up in a text editor you will most likely see an error message that will help you diagnose the problem.
If you don't see an error when you open the image in a text editor then you probably have display_errors set to 'Off' in your php.ini. If that's the case then set display_errors to 'On' and save the image again so you can see the error message.
lobo235
Posted: 2009-03-25 12:38:53 by Manny
hey, I was wondering what needs to be edited in order to resize the graph? I resized the gradient file to 100 pixels wide, and also imagecreate(102,7); and imagerectangle($per, 0, 0, 101, 6, $border);
but my graph, although works without errors, is not displaying the correct percentage in terms of graphics, any help?
but my graph, although works without errors, is not displaying the correct percentage in terms of graphics, any help?
Posted: 2009-09-03 13:03:46 by l0nelyc0wboy
Thank you. Code is small and easy to integrate with web cms
Posted: 2009-09-03 13:03:56 by l0nelyc0wboy
@Manny: i've resize the image not from the code, but from the <img> tag and works fine :)
Eg:
<img src="graph.php?per=68.5" height="15" alt="76.82% graph" />
Eg:
<img src="graph.php?per=68.5" height="15" alt="76.82% graph" />
Posted: 2009-09-30 10:22:54 by Chemi
I would personal have ended the code with a:
imagedestroy($per);
Make things faster :D
imagedestroy($per);
Make things faster :D
Posted: 2010-02-16 22:24:12 by Kaitora
Thanks for your amazing tutorial. It's really helped me to get to grasps with creating a dynamic graph image. What I would like to know though, is how do I change the size of the border? I would like to make the border thicker, and is it possible to use HEX colours?
Subscribe to the comments for this article
Post your comment for the Displaying a percentage bar using PHP article:
