kevinritt Posted April 26, 2009 Share Posted April 26, 2009 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 More sharing options...
Mchl Posted April 26, 2009 Share Posted April 26, 2009 How do you store results? Link to comment https://forums.phpfreaks.com/topic/155739-survey-results-to-show-as-a-graphic/#findComment-819770 Share on other sites More sharing options...
.josh Posted April 26, 2009 Share Posted April 26, 2009 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.. Link to comment https://forums.phpfreaks.com/topic/155739-survey-results-to-show-as-a-graphic/#findComment-819773 Share on other sites More sharing options...
kevinritt Posted April 26, 2009 Author Share Posted April 26, 2009 How do you store results? Sorry, I have a MySQL table set up to capture the selections of yes/ no on both questions Link to comment https://forums.phpfreaks.com/topic/155739-survey-results-to-show-as-a-graphic/#findComment-819774 Share on other sites More sharing options...
Mchl Posted April 26, 2009 Share Posted April 26, 2009 Then just count the rows. http://dev.mysql.com/doc/refman/5.1/en/counting-rows.html Link to comment https://forums.phpfreaks.com/topic/155739-survey-results-to-show-as-a-graphic/#findComment-819775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.