PDA

View Full Version : having some problems with an if condition + forumula


Spank
02 Aug 2008, 23:16
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:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


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


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



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

MoT3rror
02 Aug 2008, 23:19
That is template if condition, it doesn't work in php.

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Spank
02 Aug 2008, 23:29
Thanks MoT3rror, but where would I put this? If it's where I want the percentage displayed I wouldn't need the $percentage, would I?

Right now I have the formula a plugin in the hook and then just type $percentage where I want the percentage displayed.

MoT3rror
02 Aug 2008, 23:36
You would find a hook that is where you need this code and before the template is called. Then you can put $percentage in your template.

Spank
02 Aug 2008, 23:43
I love you! It works great! Thanks =)