473,614 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

generate bar / graph from database

I got an online survey working where each submission outputs to a table
on another page. It works, but now I would like to be able to create
another page that would show the totals in a bar / graph. There are 5
questions with 6 radio buttons each (and a comments field). There is
also one drop-down menu I would like to interpret as well. Can anyone
point me to a good tutorial. Most of the scripts I've seen starts with
creating a poll which I've already done.
Jul 17 '05 #1
3 3304
I noticed that Message-ID: <LP************ **********@news .easynews.com>
from Neal contained the following:
It works, but now I would like to be able to create
another page that would show the totals in a bar / graph. There are 5
questions with 6 radio buttons each (and a comments field). There is
also one drop-down menu I would like to interpret as well.


A bit like this perhaps?
http://www.ckdog.co.uk/php/voting/re...php?ballotid=3

I assume you have a method of storing your results?

All I did here was to set the percentage width of a single pixel .gif to
the required width. But you could just as easily do it with divs or
table cell widths.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Geoff Berrow wrote:
A bit like this perhaps?
http://www.ckdog.co.uk/php/voting/re...php?ballotid=3

I assume you have a method of storing your results?

All I did here was to set the percentage width of a single pixel .gif to
the required width. But you could just as easily do it with divs or
table cell widths.


yes.....somethi ng like that. My results are stored in MySQL database
with fields qone, qtwo, qthree, etc...
Each question has 6 possible answers / values ranging from Excellent to
Unsatisfactory. Can I see your source code?
Jul 17 '05 #3
I noticed that Message-ID: <Km************ **********@news .easynews.com>
from Neal contained the following:
yes.....someth ing like that. My results are stored in MySQL database
with fields qone, qtwo, qthree, etc...
Each question has 6 possible answers / values ranging from Excellent to
Unsatisfactory . Can I see your source code?


Because this is designed to be re-used for all sorts of different votes,
I store the choices as a comma separated list in the ballot table, but
of course there is only one question. Anyway, if it helps, see below
for the relevant bit of code. Looking through it, I think the html is a
little screwed, but it works and the only thing the validator picks up
is missing alt attributes on the .gifs used for the bars..

....
$ballotid=$_GET['ballotid'];
$db = @mysql_connect( "server", "user", "password") or
die("Could not connect: " . mysql_error()); ;
mysql_select_db ("database_name ",$db);

$sql="SELECT * from ballot WHERE ballotid='$ball otid' AND
end_date>now()" ;
$result = mysql_query($sq l);
$vote_finished = mysql_num_rows( $result);

$sql="SELECT * from ballot,vote,vot er WHERE ballot.ballotid ='$ballotid'
AND ballot.ballotid =vote.ballotid and voter.voterid=v ote.voterid AND
vote.confirmed= 'Yes'AND (status is null OR status='OK')";
$result = mysql_query($sq l);
$totalrows = mysql_num_rows( $result);
$myrow = mysql_fetch_arr ay($result);
?>
<body bgcolor="#FFFFF F" text="#000000">
<h1 align="center"> GB Voting </h1>
<h2 align="center"> Welcome to the results page</h2>
<h2 align="center"> The issue in question is:</h2>
<h1 align="center"> <?php print $myrow['description']; ?></h1>

if($vote_finish ed>0){
print"<h3 align=\"center\ "><a href=\"vote.php ?$ballotid\">Vo te still
running</a></h3>";
$result = mysql_query("SE LECT UNIX_TIMESTAMP( end_date) AS unixdate FROM
ballot WHERE ballotid='$_GET[ballotid]'" ,$db);
$myrow = mysql_fetch_arr ay($result);
$RealDate = date("F jS, Y", $myrow["unixdate"]);
print "<h1 align=\"center\ " class=\red\">Re sults available on
$RealDate</h1></body></html>";
exit;
}
?>
<h3 align="center"> Only confirmed votes (<?php print $totalrows; ?>) are
counted</h3>
<?php

//summary

$choices= explode(",", $myrow['choices']);

if($totalrows>0 ){
print"<hr size=\"1\" width=\"90%\">< table width=\"75%\" border=\"0\"
cellspacing=\"0 \" cellpadding=\"3 \" align=\"center\ ">";

for ($i=1;$i<count( $choices); $i++){
$picked=trim(ad dslashes($choic es[$i]));
$sql="SELECT * from vote WHERE choice='$picked ' AND confirmed='Yes' AND
ballotid='$_GET[ballotid]'AND (status is null OR status='OK')";

$result = mysql_query($sq l);
$numrows=mysql_ numrows($result );

$percent=number _format(($numro ws*100/$totalrows),1);
print "<tr>
<td width=\"39%\"al ign=\"right\">< b>$choices[$i]</b></td>
<td width=\"21%\">& nbsp;=&nbsp; <b>$numrows</b> ($percent%)</td>
<td width=\"40%\">< table width=\"100%\" border=\"0\"
cellspacing=\"0 \" cellpadding=\"0 \">
<tr>
<td class=\"border\ "><img src=\"redline.g if\" width=\"$percen t%\"
height=\"3\"></td>
</tr>
</table></td>
</tr>";
}
print "</table>";
//end summary
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2198
by: Timin Uram | last post by:
I'm not sure if this forum is the correct place to post this, but I couldn't think of any other group. I would really appreciate any help you could give me. FINAL GOAL OF MY APPLICATION: Building a friendster clone for a very large organization (10,000 people). I am using Php/Mysql. SETUP OF SYSTEM: (it may help if you are familiar with how friendster works)
6
6547
by: Tarek | last post by:
hi, May I want to know ASP or Javascript can generate a chart (pie chart) ? or other method can do that? I feel appreciate that anyone can help me ! ^^' -- Regards, Tarek ^^'
2
2928
by: KevinGPO | last post by:
I am making a monitor program for the PC. My monitor program will grab statistics about CPU and memory every 1 or 5 seconds. Then I want to store this data so I have a history and hence be able to graph this out in my GUI. I thought about using a plain text file to store my graph data and plot it out. Plot it out manually or use gnuplot. I found this tool called RRDTool (http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/). It's a...
3
4156
by: Vincenzino | last post by:
Hi, I have some problem in using SQL3 recursive queries on DB2 database system (8.1 and 8.2 UDB). I need to compute the transitive closure of a (possibly) ciclic graph using SQL3 on DB2. I MUST use pure SQL3 and I cannot use cursors, indexes and the like. The graph is represented by a set of arcs with the table "arc" having two attributes "a1" and "a2" for source and target nodes resp. The SQL3 query I'm using is the following:
2
2528
by: Jeff Blee | last post by:
I am hoping someone can help me. I am making a Access 97 app for a person and have run up against a problem to do with MS Graph. There is a table that has a number of data elements and a date field and entries are entered each month. A graph is required that has three of the data elements represented basically on the y axis and time as months along the x axis. So for each month there is a group of three columns representing the data...
0
1225
by: z.ghulam | last post by:
Hi, I have a line graph used to tally up the number of orders each engineer does in a week. This works well apart from 2 things: 1) If an engineer is off for a week or completes 0 orders, then there is no record of a 0 in the database and so there is a break in the line graph. Whjat I would like is the line graph to show a value of 0 for these periods. Is there any way to get Access to create a default zero value in the graph if no...
0
1701
by: ptkumar | last post by:
Hi All, I am using JfreeCharts. I have to generate an image(Pie Graph) in a jsp file. That jsp file image should be display into an .xls file. please help me on this. kumar
1
1797
by: srinivasreddypn | last post by:
Hi everyone, is it possible to generate a line graph in flash by calling xml data into flash. m seeking for any reference. please help me thank u, srinvas
3
4696
by: The Frog | last post by:
Hi guys, I have never touched really on this area before with forms and reports, and now I would like to be able to incorporate some graphs / charts for a new little app I am building, and I need some guidance. Can someone point me in the right direction? 1/ What is the difference between MS Chart and MS Graph? 2/ Which is better to work with for Access 97?
0
8623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8576
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6088
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4050
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4121
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1423
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.