Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
wiz
Involved
Involved



Joined: Oct 09, 2006
Posts: 413
Location: UK

PostPosted: Sun Oct 19, 2008 5:42 am Reply with quote

Hi, i have 2 figures set with vars, and i want to display the differance as a percentage, for example the price of an item in a store. Here is the code i have:
Code:
// Low//

$al = "50";
// High//
$ah = "100";
$gaina = round(($al / $ah)*100,0);
echo "You will make a maximum" .$gaina. "% profit on this item!!";


The idea is that, if the low price is £50 and the high price is £100. So if you bought it at £50 and sell it at £100, you will make 100% profit.
However the numbers that it outputs are wrong.
Any ideas?
 
View user's profile Send private message Visit poster's website AIM Address
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sun Oct 19, 2008 12:39 pm Reply with quote

The math isn't correct. You need to determine % of profit. It should be:

(($ah - $al)/$al)*100

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
wiz







PostPosted: Sun Oct 19, 2008 12:57 pm Reply with quote

I thought that i had got the calculations wrong
cheers Montego
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©