Page 1 of 1

REQ: some sort of calc

Posted: Sat Feb 09, 2008 9:16 am
by dastylex
hi
im looking for some sort of php calculator...
like:
if i enter some value (suppose X value) into it.. it calculates 15% of that X value and add the result into X value..

for example..
X value = 230
it calculates like this 230 x 15% = 34.5
and it adds it back to X value.. in this case...
34.5 + 230 = 264.5


final result it must show is 264.5

nothing is to be changed.. only X value is variable and has to be changed everytime i want to calculate.

can u help me please? i want it urgent.
thanks
bye

Re: REQ: some sort of calc

Posted: Sat Feb 09, 2008 9:27 am
by Christopher

Code: Select all

$percent = 15;
$x = 230;
$total = $x - ($x * ($percent / 100));

Re: REQ: some sort of calc

Posted: Sat Feb 09, 2008 10:59 am
by John Cartwright
arborint wrote:

Code: Select all

$percent = 15;
$x = 230;
$total = $x - ($x * ($percent / 100));
$x +

instead of

$x -

:mrgreen:

Re: REQ: some sort of calc

Posted: Sat Feb 09, 2008 12:40 pm
by Christopher
Shows how ingrained discount calculations are in by brain. :crazy:

Re: REQ: some sort of calc

Posted: Mon Feb 11, 2008 7:00 am
by dastylex
sorry but guys.. im totally a noob in programming.. can u guide me how to make this thing work on php ? :oops:

so i dont have to put in percentage everytime.. i just enter the value and it shows the rslt!