xoluz Posted March 17, 2006 Share Posted March 17, 2006 Hi was wondering something, I've got the following code now:[code]$ruletotal = $array['amount'] * $array['price'];$formtotal = array_sum($ruletotal)[/code]This thing works imo, but now I want to add something to it. When the '$formtotal' is more than 50 000, I want to calculate 10% of it. So i got this added, but something isn't working:[code]if ($formtotal = 50000) {$discount = $formtotal /100*10; }else { echo 'no discount';}$total = $formtotal - $discount;echo 'Total: $total';[/code]Could someone help me out here..? :) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 17, 2006 Share Posted March 17, 2006 You need to use "==" not "=". But you said you wanted this to happen "When the '$formtotal' is more than 50 000"[code]<?phpif ($formtotal > 50000) $discount = $formtotal * 0.1;else echo 'no discount<br>';$total = $formtotal - $discount;echo 'Total: $total';?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
xoluz Posted March 17, 2006 Author Share Posted March 17, 2006 [!--quoteo(post=355956:date=Mar 18 2006, 04:05 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 18 2006, 04:05 AM) [snapback]355956[/snapback][/div][div class=\'quotemain\'][!--quotec--]You need to use "==" not "=". But you said you wanted this to happen "When the '$formtotal' is more than 50 000"[code]<?phpif ($formtotal > 50000) $discount = $formtotal * 0.1;else echo 'no discount<br>';$total = $formtotal - $discount;echo 'Total: $total';?>[/code]Ken[/quote]Thanks! That works perfect :)And I forgot about the ==, it should be > like you said ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.