<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: Polls... how to show results</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: Polls... how to show results</description>
<language>en</language>
<pubDate>Mon, 04 May 2026 02:44:53 +0000</pubDate>

<item>
<title>garybpenn on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-16831</link>
<pubDate>Sat, 19 Jan 2013 00:45:43 +0000</pubDate>
<dc:creator>garybpenn</dc:creator>
<guid isPermaLink="false">16831@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;ggmaury - &#60;/p&#62;
&#60;p&#62;I am attempting to do the same thing that you did here several years back.  That is, show instant results after a poll is submitted.  Can you possible turn the example links back on or share your code?  Thank you!
&#60;/p&#62;</description>
</item>
<item>
<title>girljinbink on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1872</link>
<pubDate>Wed, 21 May 2008 23:15:54 +0000</pubDate>
<dc:creator>girljinbink</dc:creator>
<guid isPermaLink="false">1872@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I'm at a beginning level of PHP, so although I understand most of what you're saying, there are some holes...&#60;/p&#62;
&#60;p&#62;would you be willing to send me the code for your results page?&#60;br /&#62;
mjohnson(at)tcgrec.com
&#60;/p&#62;</description>
</item>
<item>
<title>ggmaury on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1858</link>
<pubDate>Wed, 21 May 2008 00:57:24 +0000</pubDate>
<dc:creator>ggmaury</dc:creator>
<guid isPermaLink="false">1858@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;AMurray:&#60;/p&#62;
&#60;p&#62;Sorry, I disabled that form.&#60;br /&#62;
You can check an example in &#60;a href=&#34;http://campeche.com/encuestas/index.php?id_1=8&#38;#38;id_2=1&#38;#38;id_3=0&#38;#38;id_4=0&#34; rel=&#34;nofollow&#34;&#62;http://campeche.com/encuestas/index.php?id_1=8&#38;#38;id_2=1&#38;#38;id_3=0&#38;#38;id_4=0&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;girljinbink:&#60;/p&#62;
&#60;p&#62;I made a machform directory where I use only 1 field multiple choice forms.&#60;/p&#62;
&#60;p&#62;The machform db structure includes a table called 'ap_element_options' where field 'form_id' is the number of the form you want to show results from. All rows with the same 'form_id' will have different 'position' (or 'option_id' which have the same values). Each 'position' is a choice for the form.&#60;/p&#62;
&#60;p&#62;By querying ($id is the form number passed in the url so the same script takes care of all polls):&#60;/p&#62;
&#60;p&#62;$result = mysql_query(&#34;SELECT &#60;code&#62;position&#60;/code&#62;, &#60;code&#62;option&#60;/code&#62; FROM &#60;code&#62;ap_element_options&#60;/code&#62; WHERE &#60;code&#62;form_id&#60;/code&#62; = '$id'&#34;);&#60;/p&#62;
&#60;p&#62;you will get all rows with the same &#60;code&#62;form_id&#60;/code&#62; thus getting all choices (choice number and name) of your poll:&#60;/p&#62;
&#60;p&#62;while ($row = mysql_fetch_array($result))&#60;br /&#62;
        {&#60;br /&#62;
	$choice[$total]['position'] = $row['position']; //choice number&#60;br /&#62;
	$choice[$total]['option'] = $row['option'];     //text describing choice&#60;br /&#62;
	$choice[$total]['votes'] = 0;                   //will store total votes per choice &#60;/p&#62;
&#60;p&#62;	$total++;&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;At this point, you have a multidimentional array holding poll values.&#60;/p&#62;
&#60;p&#62;Then you count the number of times (rows) each choice has been selected (I used a for loop based on $total). Those are saved in table 'ap_form_x' where 'x' is your 'form_id' and field &#60;code&#62;element_1&#60;/code&#62; has the same value than 'option':&#60;/p&#62;
&#60;p&#62;$result = mysql_query(&#34;SELECT &#60;code&#62;element_1&#60;/code&#62; , COUNT( * ) as &#60;code&#62;votes&#60;/code&#62; FROM &#34;.$apform.&#34; WHERE &#60;code&#62;element_1&#60;/code&#62; ='$i' GROUP BY &#60;code&#62;element_1&#60;/code&#62;&#34;);&#60;/p&#62;
&#60;p&#62;$row = mysql_fetch_array($result);&#60;br /&#62;
	$choice[$i]['votos'] = (int)$row['votes'];&#60;br /&#62;
	$totalVotes = $totalVotes + $choice[$i]['votes'];&#60;/p&#62;
&#60;p&#62;then I sort the array based on total votes to show them from max to min votes.&#60;/p&#62;
&#60;p&#62;From that point you display the results of your poll.&#60;/p&#62;
&#60;p&#62;I hope that helps.
&#60;/p&#62;</description>
</item>
<item>
<title>AMurray on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1834</link>
<pubDate>Sat, 17 May 2008 09:07:41 +0000</pubDate>
<dc:creator>AMurray</dc:creator>
<guid isPermaLink="false">1834@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I don't see anything except a blank screen with green background.....no poll or results there.
&#60;/p&#62;</description>
</item>
<item>
<title>girljinbink on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1805</link>
<pubDate>Thu, 15 May 2008 23:01:18 +0000</pubDate>
<dc:creator>girljinbink</dc:creator>
<guid isPermaLink="false">1805@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Can you elaborate a bit more on how you coded the results page?
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1729</link>
<pubDate>Fri, 09 May 2008 14:33:01 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">1729@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;ooh.. that looks nice!
&#60;/p&#62;</description>
</item>
<item>
<title>ggmaury on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1714</link>
<pubDate>Fri, 09 May 2008 02:45:14 +0000</pubDate>
<dc:creator>ggmaury</dc:creator>
<guid isPermaLink="false">1714@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Yuniar:&#60;br /&#62;
I achieved that by accessing the database and using form_id, position and option from ap_element_options table to select the form and then count the votes contained in element_1 (table ap_form1, ap_form2 and so on depending on the form number).&#60;br /&#62;
If works for a single multiple choice field and redirects to my results viewer.&#60;br /&#62;
check it out at:&#60;br /&#62;
&#60;a href=&#34;http://campeche.com/encuestas/formas/view.php?id=1&#34; rel=&#34;nofollow&#34;&#62;http://campeche.com/encuestas/formas/view.php?id=1&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;There are 4 forms so changong the id to 2, 3 or 4 you can see the others.&#60;/p&#62;
&#60;p&#62;I just need to make a page with a menu of available polls to control the flow.
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1241</link>
<pubDate>Sat, 29 Mar 2008 15:07:34 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">1241@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Sorry, I'm afraid I can't help much with this one, since it would require pretty much custom code.
&#60;/p&#62;</description>
</item>
<item>
<title>ggmaury on "Polls... how to show results"</title>
<link>https://www.machform.com/forums/topic/polls-how-to-show-results#post-1239</link>
<pubDate>Sat, 29 Mar 2008 11:12:16 +0000</pubDate>
<dc:creator>ggmaury</dc:creator>
<guid isPermaLink="false">1239@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I just made a form to make a poll. The form works fine but I need to display the results with the total votes per choice and the percentage each one has.&#60;br /&#62;
I know I can export the values to xls or csv but I need to get them automaticly right after each vote.&#60;br /&#62;
Can you suggest any workaround?&#60;br /&#62;
Maybe updating the csv automaticly after casting a vote?&#60;/p&#62;
&#60;p&#62;Thanks
&#60;/p&#62;</description>
</item>

</channel>
</rss>
