?
Solved

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

Posted on 2004-08-22
4
Medium Priority
?
513 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

777 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