Jump to content

survey results to show as a graphic


kevinritt

Recommended Posts

Hello,

I have a form set up to take an online survey that asks 2 questions.

<form action="" method="post">
Are you satisfied with the current administrator's job?<br />
<input name="current" type="radio" value="yes" />Yes<br />
<input name="current" type="radio" value="no" />No<br />
<br />
Will you vote for your current party affiliation in the next election?<br />
<input name="affiliation" type="radio" value="yes" />Yes<br />
<input name="affiliation" type="radio" value="no" />No<br />
</form>

What I'm trying to do is show the current results of the survey as a bar graph and percentage instead of just a number. How would I determine how many people entered the surver to display % results? Is this possible?

Link to comment
https://forums.phpfreaks.com/topic/155739-survey-results-to-show-as-a-graphic/
Share on other sites

simple math...

 

$percentyes = ($totalyes / $total) * 100; // percent of people who entered 'yes'

 

How you populate those vars depends on how you are storing the data, as Mchl pointed out.  As far as displaying it as a graph, you would have to dynamically build an image using gd library.  Or you could just google for one of the millions of prefab scripts that already do that..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.