Categories > TinyButStrong general >

abs()

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SunWuKung
Date: 2007-01-17
Time: 14:15

abs()

Is there a way to place a condition on the absolute value of a [var] ?

Thx.
SWK

By: Skrol29
Date: 2007-01-17
Time: 15:01

Re: abs()

I don't think so.
You have to use an extra calculated variable or a custom "onformat" function.
By: TomH
Date: 2007-01-17
Time: 15:39

Re: abs()

If your var is not from a query then do the
$var=abs($var);
on the php side before you do the template

If your var is from MySQL then do the conversion as part of the query so you will have tha absolute value already in the result set when you process the block
i.e.    mysql> SELECT NAME, ABS(SCORE) AS ABSCORE FROM TABLE;