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
Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 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