PDA

View Full Version : poll trouble


Needasphelp
09-27-2005, 02:09 PM
Hello all. I have created a voting poll but am having trouble displaying the results. Basically, you can add a poll question and give it as many answers as you want through the admin section. When a user votes, it shows how many votes each answer has got eg:

Answer 1 : 6
Answer 2 : 4

Then I have some sql SELECT SUM(a_total)
From the table getting the variables from the poll ID. This also works fine for displaying, " 10 votes have been cast."

Problem is now displaying the percentages for the results ie:
Answer 1 : 60%
Answer 2 : 40%

Could anyone please help me. I really don't know how to do this.
Many thanks.

Roman
09-29-2005, 06:58 AM
For example:

<table width="100%">
<tr>
<td>
<? echo $answer; ?>
</td>
<td>
<table width="100%">
<tr>
<td width="<? echo $result_in_percent; ?>" bgcolor="#FF0000"><? echo $result; ?></td>
<td width="*">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>

cubsfan
09-30-2005, 06:15 AM
Are you looking for a sql statement to calculate the percentage?

chhawchharia
11-28-2005, 08:45 AM
u can make it using MYSQL php
first make connection with database then each poll will get regitered there
then then count it and then back display
it let first u inform me till were u have done