Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Rounding a template var.
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Rounding a template var.
I am working on presenting some threadfield results in a star format (like the rating system) and I am struggling on the rounding of the outputted values. I need them to be a number like 1.5 or 2 or 2.5 etc, but I cannot figure out the correct conditional to do this.

This is my code so far:

Code:
<setvar q>$GLOBALS['threadfields']['pfrating1']+$GLOBALS['threadfields']['pfrating2']+$GLOBALS['threadfields']['pfrating2']</setvar>


The values for the threadfields are 3, 3 and 2 which gives me a result of 8.
I then divided 8 by 3

Code:
<setvar r>$tplvars['q']/3</setvar>


and that gave me a result of 2.66666667 and it is this number I want to round to 2.5.

I tried the code below but it just gave no output. I was hoping it would round it to the decimal point.

Code:
<?=round("$tplvars['r']",1)?>


All help appreciated.



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 04-21-2013 05:15 PM by leefish.)
04-21-2013 04:42 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Rounding a template var. - leefish - 04-21-2013 04:42 AM
RE: Rounding a template var. - ZiNgA BuRgA - 04-21-2013, 04:58 PM
RE: Rounding a template var. - leefish - 04-21-2013, 06:17 PM
RE: Rounding a template var. - ZiNgA BuRgA - 04-21-2013, 07:30 PM
RE: Rounding a template var. - leefish - 04-21-2013, 08:19 PM
RE: Rounding a template var. - ZiNgA BuRgA - 04-21-2013, 09:39 PM
RE: Rounding a template var. - leefish - 04-21-2013, 09:47 PM
RE: Rounding a template var. - leefish - 05-05-2013, 02:20 AM
RE: Rounding a template var. - ZiNgA BuRgA - 05-05-2013, 10:09 PM
RE: Rounding a template var. - leefish - 05-10-2013, 02:36 AM
RE: Rounding a template var. - ZiNgA BuRgA - 05-10-2013, 09:37 AM
RE: Rounding a template var. - leefish - 05-10-2013, 06:04 PM
RE: Rounding a template var. - ZiNgA BuRgA - 05-12-2013, 11:04 AM
RE: Rounding a template var. - leefish - 05-12-2013, 11:48 PM
RE: Rounding a template var. - ZiNgA BuRgA - 05-13-2013, 02:11 PM
RE: Rounding a template var. - leefish - 05-13-2013, 09:25 PM
RE: Rounding a template var. - ZiNgA BuRgA - 05-14-2013, 09:34 AM
RE: Rounding a template var. - leefish - 05-14-2013, 06:48 PM

 Standard Tools
Forum Jump: