• 0

PHP Poll


Question

I'm making a poll for my site in PHP, it uses flat text files to hold the values, so basically the poll is working, it hold the votes in an array called count[0] until count[5], what I want to be able to do is show the bar under each vote like most poll scripts do.

I can put 10x1 image and times it by count and that make the bar grow ie : 10 votes and the bar will be 10 pixels long.

But what I want is it to behave like all the other polls I have seen 1 vote would be 100%, 2 votes 50%, etc, etc . . .

I hope you understand what I'm trying to achieve, if a 1000 people voted on option one on the current way I have done it then the bar would be 1000 pixels in length, what I need is the mathematical way to sort this out.

Can anybody help me with this ? :unsure:

Kind regards

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

em simple maths - GCSE level

number of votes / total votes x 100

php -

$1 = count[0] / $totalvotes;

$score = $1 * 100;

sumot like that

edit*

Large - whats your site?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.