Solved

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

Posted on 2004-08-22
4
503 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
4 Comments
 
LVL 26

Accepted Solution

by:
ushastry earned 63 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 62 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 count occurrences of each item in an array.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now