1. ## Calculations

I have a donation Centre set up with a goal of £100.000. So far £5 has been donated and the centre is showing it as 5% Done.

I have this in my config.php
Code:
```// Your goal in USD:
\$goal = 100.000;```
and I have this in my donate.php

Code:
```// Calculating how many percent of the goal were met:
\$percent = round(min(100.000*(\$sum/\$goal),100.000));```
What is missing or wrong?

2. There's nothing wrong - 5 is 5% of 100 so the answer is correct. The number of zeros after the decimal point doesn't change anything so I don't know why you are including three zeros there particularly since the third zero represents tenths of a penny.

3. Maybe the op means 100k?
(In which case 100.000 should be written without the decimal point).

4. Originally Posted by Pullo
Maybe the op means 100k?
(In which case 100.000 should be written without the decimal point).
Yeah, some places in europe use a decimal instead of a comma... either way it shouldn't be in there

5. yes that's right I mean 100k so I got rid of the decimal point and that changes it from 5% done to 0% done and changing the goal to 50000 makes it 5% done.
Could someone explain to me what this code is for? What is the difference for the min100000 and the other 100000 as there are two 100000?

Code:
```// Calculating how many percent of the goal were met:
\$percent = round(min(100000*(\$sum/\$goal),100000));```

6. Hi,

Have a look at this: http://www.phpbook.net/how-to-calcul...-with-php.html
That should helpwith what you want to do.

7. I've had a look at that and not only am I bad at maths but my php knowlege is next to nothing. I've tried all sorts of different variations and I'm not getting the desired result/ So now I have £10 worth of donations and a goal of £100.000 showing 19% done.

here is my current setting:

\$percent = round(min(100000*(\$sum/\$goal),100000));

could someone let me know that correct way to do it?
Much appreciation

8. No problem:

PHP Code:
``` \$have = 10; \$target = 100000; \$percentage = ( \$have / \$target) * 100; \$percentageToTwoDecimalPlaces = round(\$percentage, 2); echo "We have raised £\$have, out of £\$target.<br />"; echo "We have achieved \$percentageToTwoDecimalPlaces% of our target";  ```
Hope that helps.

9. I know your spelling this out for me but I'm still not getting it right:

Code:
```// Calculating how many percent of the goal were met:
\$have = 10;
\$target = 100000;
\$percentage = ( \$have / \$target) * 100;
\$percentageToTwoDecimalPlaces = round(\$percentage, 2);```
then further down the page I changed it to this:

Code:
```<div class="donations">
<?php \$percentageToTwoDecimalPlaces?>% done
</div>```

Code:
```// Calculating how many percent of the goal were met:
\$percent = round(min(100000*(\$sum/\$goal),100000));```
and then:

Code:
```iv class="donations">
<?php echo \$percent?>% done
</div>```
Can I not just change the sums in the \$percent = round(min(100000*(\$sum/\$goal),100000)); part?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•