Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PHP and Ghraphics

Creating Bar graphs without GD Lib by 4x4uk
Posted: 16 Feb 03

If you can't or don't want to install GD Lib but still want to be able to manipulate images then this may be of interest to you. Particularly if you want to produce some simple bar graphs as I did.

First of all create a 2*10 pixel gif image (called bar.gif in this eaxmple)
then have a look at the script below and modify it to suit your own needs

// set the graphic scaling value
// use this to increase the size of the graphics

// Use your own values here ie results from mysql query etc


//Calculate Value as a pecentage with 1 decimal place showing

// Multiply Percentage value by Graphic scaling value
// Not totally necessary but this gives a level of
// control over the final graph size    
// Output the data

<table border=\"0\"><tr>
<td><b>Value 1</b></td><td width=\"150px\"></td><td align=\"center\"><b>%</b></td><td><b>Count</b></td>
<tr><td>Value 1</td>
<img src=\"bar.gif\" width=\"$bar1\" height=\"10\" hspace=\"0\" vspace=\"0\" border=\"0\" align=\"top\">
</td><td align=\"right\">$pcv1</td><td align=\"right\">$value1</td>
<td>Value 2</td><td>
<img src=\"bar.gif\" width=\"$bar2\" height=\"10\" hspace=\"0\" vspace=\"0\" border=\"0\" align=\"top\">
</td><td align=\"right\">$pcv2</td><td align=\"right\">$value2</td>
<td>Value 3</td><td>
<img src=\"bar.gif\" width=\"$bar3\" height=\"10\" hspace=\"0\" vspace=\"0\" border=\"0\" align=\"top\">
</td><td align=\"right\">$pcv3</td><td align=\"right\">$value3</td>

Back to PHP FAQ Index
Back to PHP Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close