Solved

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

Posted on 2004-08-22
4
500 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now