Hello everyone 🙂
I have an online poll script. Within that script, it talies the results into percentages, then displays that with a dynamic bar graph (uses a 1 pixel wide image and uses the percentage as the width tag for the image - if anyone wants this script - Ill give it away for free 🙂 )
The only problem is that the percentages are not limited. They show up as 18.1216681848387
and such.
Is there a way to round the number so that there isn't anything past the decimal space, or so that there are only a couple of numbers shown past the decimal place?
Any help would be greatly appreciated.
Thanks!
Lazzerous
Here's the code used to make the percentages I'm using now:
<?
mysql_connect("localhost", username, pass);
mysql_select_db('dbname');
$joke = "insert into polls VALUES('$rd','$ip')";
$er = mysql_query($joke);
$moan = "select rd from polls where rd like '1'";
$hard = mysql_query($moan);
$moantwo = "select rd from polls where rd like '2'";
$hardtwo = mysql_query($moantwo);
$moanthree = "select rd from polls where rd like '3'";
$hardthree = mysql_query($moanthree);
$moanfour = "select rd from polls where rd like '4'";
$hardfour = mysql_query($moanfour);
$moanfive = "select rd from polls where rd like '5'";
$hardfive = mysql_query($moanfive);
$moaning = "select rd from polls";
$harder = mysql_query($moaning);
$one = mysql_num_rows($hard);
$two = mysql_num_rows($hardtwo);
$three = mysql_num_rows($hardthree);
$four = mysql_num_rows($hardfour);
$five = mysql_num_rows($hardfive);
$all = mysql_num_rows($harder);
$percentone = (100 / $all) * $one;
$percenttwo = (100 / $all) * $two;
$percentthree = (100 / $all) * $three;
$percentfour = (100 / $all) * $four;
$percentfive = (100 / $all) * $five;
?>