rebstech

Bar Graphics with PHP

Q: Can I make a bar graphics for some statistic with PHP?
A: Yes.. It very simple tricks with PHP

Q: Can you tell me, how to make it?
A: OK.. I will tell it for you.. Please look at this very-very small picture of yellow, red and green blocks. Can you see it?

A: Can you see?

A: This picture is generate by this code:

<img src="//www.rebstech.com/wp-content/uploads/2009/06/yellow.jpg”" alt="" /> <img src="//www.rebstech.com/wp-content/uploads/2009/06/red.jpg”" alt="" /> <img src="//www.rebstech.com/wp-content/uploads/2009/06/green.jpg”" alt="" />

A: This picture, have a height, and width. You can change this value like it

<img src="//www.rebstech.com/wp-content/uploads/2009/06/yellow.jpg”" alt="" /> <img src="//www.rebstech.com/wp-content/uploads/2009/06/red.jpg”" alt="" /> <img src="//www.rebstech.com/wp-content/uploads/2009/06/green.jpg”" alt="" />

A: The result of this code like that:

A: Now, you can control in your PHP Code like this

if($barwidth&lt;50){ $url=”http://www.rebstech.com/wp-content/uploads/2009/06/green.jpg”; }elseif($barwidth=50) {$url=”http://www.rebstech.com/wp-content/uploads/2009/06/yellow.jpg”; } elseif($barwidth&gt;50) {  $url=”http://www.rebstech.com/wp-content/uploads/2009/06/red.jpg”;}  echo “<img src="’$url’" alt="" />”;

Please set $barwidth for the value of your statistic.

Q: I ll try… TQ

A: For advance, hire us.. :)

No Comments

Leave a Reply