Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to create bar graph using gd library using data from mysql table

Posted on 2004-08-22
4
Medium Priority
?
516 Views
Last Modified: 2013-12-12
GD library is installed on my pc so i try to use this to create bar graph but i am new to this.

Can anyone help me. I want to create bargraph using values from one of the fields (votes) from table (list) created in mysql.

Please help
0
Comment
Question by:aynsoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 26

Accepted Solution

by:
Umesh earned 252 total points
ID: 11868094
Hi,

Check out this jpGraph..

http://www.aditus.nu/jpgraph/index.php


0
 
LVL 2

Assisted Solution

by:b_loco
b_loco earned 248 total points
ID: 11872756
If the use of gd is not mandatory, try this:

/*assuming
$totalvotes = total number of votes;
$votes = this particular option's number of votes;
$bgcolor = "#FF0000"; //color of the bar
$bordercolor= "#FFFFFF"; //color of the line around the bar
*/


echo "<table width=\"".(($votes/$totalvotes)*100)."\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"".$bordercolor."\">
<tr>
<td bgcolor=\"".$bgcolor."\"></td>
</tr>
</table>";


this will create a table that will simulate a bar. e.g: if it is 50% then the table will have 50 px.
This can be adjusted.


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question