$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.
poll script problems
Moderator: General Moderators
- cheatboy00
- Forum Contributor
- Posts: 151
- Joined: Sat Jun 29, 2002 10:36 am
- Location: canada
- Contact:
Try this:
You use the = in mysql, but need == for compares in php. So if you wanted to do something like:
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.
Code: Select all
$len1 = mysql_query("select count(*) from poll where vote = 1");Code: Select all
if ($x == 10) dosomething();so far, you've only got handles to the results of the queries. After that, you need
and so on for the rest of the handles
Code: Select all
$result1 = mysql_fetch_row($len1);
$numberOfVotesForOne = $result1ї0]Not sure if this will help, but thought I would offer it anyway:
http://paul.the-pearsons.net/PHPVotingBooth2.05.zip
http://paul.the-pearsons.net/PHPVotingBooth2.05.zip
- cheatboy00
- Forum Contributor
- Posts: 151
- Joined: Sat Jun 29, 2002 10:36 am
- Location: canada
- Contact: