Spank
08-02-2008, 10:16 PM
I've got a formula to work out a percentage from user fields, which is the postbit_display_start hook the formula looks like this:
$percentage = (intval($post['field7']) / intval($post['field6'])) * 100;
All works well unless any of the values in the fields are 0, the fields need to be set to 0 by default, and staff members will edit these fields.
So what I'm trying to do is add an if conditional to just display 0 if field 6 is 0
Here's what I've got
$percentage = <if condition = "(post['field6']))=0">0 </if> <else />(intval($post['field7']) / intval($post['field6'])) * 100;
Obviously it doesn't work, which is why I'm posting. If anyone can help, that'd be great. I'm so dreadfully new at this I can't work it out =D
$percentage = (intval($post['field7']) / intval($post['field6'])) * 100;
All works well unless any of the values in the fields are 0, the fields need to be set to 0 by default, and staff members will edit these fields.
So what I'm trying to do is add an if conditional to just display 0 if field 6 is 0
Here's what I've got
$percentage = <if condition = "(post['field6']))=0">0 </if> <else />(intval($post['field7']) / intval($post['field6'])) * 100;
Obviously it doesn't work, which is why I'm posting. If anyone can help, that'd be great. I'm so dreadfully new at this I can't work it out =D