Page 2 of 2

Posted: Wed Jul 03, 2002 3:46 pm
by cheatboy00
$len1 = mysql_query("select count(*) from poll where vote == 1");
$len2 = mysql_query("select count(*) from poll where vote == 2");
$len3 = mysql_query("select count(*) from poll where vote == 3");

$sum = $len1 + $len2 + $len3;

$onepre = (@($len1 / $sum) * 100);
$twopre = (@($len2 / $sum) * 100);
$twopre = (@($len3 / $sum) * 100);

thats what i have now but the numbers dont show its all just zeros....

http://dragonsblood.nicewebshost.com/cbaa/showresults.php

and for votes i voted a couple of times for 1 (which is the first option)

btw .... thanks for all the help, so far.

Posted: Wed Jul 03, 2002 5:03 pm
by Galahad
Try this:

Code: Select all

$len1 = mysql_query("select count(*) from poll where vote = 1");
You use the = in mysql, but need == for compares in php. So if you wanted to do something like:

Code: Select all

if ($x == 10) dosomething();
you need the '=='. But for a mysql query like the one above, you just use '='. Sorry about the confusion with that. I hope this works.

Posted: Wed Jul 03, 2002 5:15 pm
by llimllib
so far, you've only got handles to the results of the queries. After that, you need

Code: Select all

$result1 = mysql_fetch_row($len1);
$numberOfVotesForOne = $result1ї0]
and so on for the rest of the handles

Posted: Wed Jul 03, 2002 7:06 pm
by Wandrer
Not sure if this will help, but thought I would offer it anyway:

http://paul.the-pearsons.net/PHPVotingBooth2.05.zip

Posted: Wed Jul 03, 2002 9:02 pm
by cheatboy00
WOW.............. a round of aplause for all my wonderful helpers thanks

its now working....