Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: how to get 5% out of any given number

1. ## how to get 5% out of any given number

Does anyone know the formula in php to get 5% from any given number?
For example: like on my site it shows that lets say I made \$300.00 today and I get to keep 5% of that so now I want it to show 5% of 300 which is 60. so I would get to keep \$60.00 dollars.

How or what is the code to get 5% of any number in php?

If there are any questions please let me know! Thanks guys!

• Sounds like basic math to me...

PHP Code:
``` \$rate = 5.00; //percent \$totalAmount = 300.00 \$commission = \$totalAmount*(\$rate/100); print \$commission;  ```

• ok thanks man I freaking had a brain freeze! I went to bed way to late! lol thankx so much!

• ok so now here is my big question. I have tried a lot of things and I cant multiply 0.05 by sales (a number in the database). How would I do that with \$row['sales']; in the code?

Here is part of the code:

PHP Code:
``` <?php \$con = mysql_connect("localhost", "root", "blah"); if (!\$con)   {   die('Could not connect: ' . mysql_error());      }mysql_select_db("Bus", \$con);    \$query = "SELECT drivers.last_name, sales.meals, sales.date, sales.bus, sales.sales, sales.percent ".  "FROM drivers, sales ".     "WHERE drivers.PID = sales.drivers_DID";             \$result = mysql_query(\$query) or die(mysql_error()); // Print out the contents of each row into a table  while(\$row = mysql_fetch_array(\$result)){        echo \$row['sales']; } ?> ```

•

#### Posting Permissions

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