This topic is locked
[SOLVED]

 Trying to do some maths??

3/2/2010 4:38:11 PM
PHPRunner General questions
S
swanside author

Hello.

I am using this code, so it will display the correct values for costing.

$values["Item_Cost"] = $values["Unit_Price"]*$values["Quantity"];

$values["Line_Cost"] = $values["Item_Cost"]*$values["Additional_Cost"];

return true;



We enter the Unit_Price and the Quantity and when we press save, it puts the correct value in the Item_Cost. My problem is trying to get it to add the additional cost, as this is a percentage, so what we would enter is Unit_Price = 10, Quantity = 1, Additional_Cost = 10 Item_Cost would now = £10 but the Line_Cost = £100 I need to tell it to divide the Additional_Cost by 100, but I can not see where I could do this.

I was trying to do something like this

$values["Item_Cost"] = $values["Unit_Price"]*$values["Quantity"];

$values["Line_Cost"] = $values["Item_Cost"]*$values["Additional_Cost"]/100;

return true;



This would then give me a Line_Cost of £11, but I can not see where to put the 100? as I do not have a field, so I can not use $values

Cheers

Paul
EDITED.
Sorry Ignore me, it did work just using

$values["Item_Cost"] = $values["Unit_Price"]*$values["Quantity"];

$values["Line_Cost"] = $values["Item_Cost"]*$values["Additional_Cost"]/100;

return true;