PHP Web Host - Quality Web Hosting For All PHP Applications Just Great Software
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 63

PostPosted: Tue Nov 10, 2009 9:47 pm Reply with quote Back to top

Currently, my results page in my polls list the percentage out to the nearest hundreth. I'd like to round it to a whole number.

Here is the code for the percentage in the Survey index file:

Code:
      if($sum) {
          $percent = 100 * $optionCount / $sum;
      } else {
          $percent = 0;


Can anyone help me add the necessary code to round that value?

There is also code that prints the value that might be the one to adjust:

Code:
                printf(" %.2f%%", $percent);


Last edited by rogue3 on Tue Nov 10, 2009 9:48 pm; edited 1 time in total
View user's profile Send private message
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Tue Nov 10, 2009 9:48 pm Reply with quote Back to top

Use the round() function Smile
View user's profile Send private message Visit poster's website
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 63

PostPosted: Tue Nov 10, 2009 9:51 pm Reply with quote Back to top

Wow, fast reply!

I thought I'd tinker around with it a bit for a little trial and error and I think I might have found the fix.

I changed
Code:
                printf(" %.2f%%", $percent);


to
Code:
                printf(" %.0f%%", $percent);


It appears like it is working, as my results now are whole numbers Smile
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum