MyBB Support

years of service support

Submitted by Tutti Frutti, , Thread ID: 46643

Thread Closed
11-09-2017, 10:55 PM
#1
I have this code placed inside my postbit_classic..
Code:
<setvar years>floor((TIME_NOW-$post['regdate'])/(60*60*24*365))</setvar>
<div class="years-tags yearly-tags-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']} Years of Service</div>

One problem though it's showing 0 years of service on everyones user info, someone told me to add if statement but how would I be able to do that?

Thanks.

RE: years of service support

#2
Maybe set an if statement to ignore if your variable is 0, else print the following div?

PHP Code:
<if {$GLOBALS['tplvars']['years']} !== "0" then>
<
div class="years-tags yearly-tags-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']} Years of Service</div>
</if> 

RE: years of service support

OP
#3
11-09-2017, 11:39 PM
KituKatu Wrote:
Maybe set an if statement to ignore if your variable is 0, else print the following div?

PHP Code:
<if {$GLOBALS['tplvars']['years']} !== "0" then>
<
div class="years-tags yearly-tags-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']} Years of Service</div>
</if> 

What?
I just want 0 years to be removed nothing else though??

RE: years of service support

#4
Ugh you coul've said you don't know squat about php beforehand.
Replace

Code:
<setvar years>floor((TIME_NOW-$post['regdate'])/(60*60*24*365))</setvar>
<div class="years-tags yearly-tags-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']} Years of Service</div>
With
PHP Code:
<setvar years>floor((TIME_NOW-$post['regdate'])/(60*60*24*365))</setvar>
<if{
$GLOBALS['tplvars']['years']}!=="0"then>
<
divclass="years-tagsyearly-tags-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']}YearsofService</div>
</if> 

It might work, it might not. I'm not a wold class programmer

RE: years of service support

OP
#5
11-09-2017, 11:51 PM
KituKatu Wrote:
Ugh you coul've said you don't know squat about php beforehand.
Replace

Code:
<setvar years>floor((TIME_NOW-$post['regdate'])/(60*60*24*365))</setvar>
<div class="years-tags yearly-tags-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']} Years of Service</div>
With
PHP Code:
<setvar years>floor((TIME_NOW-$post['regdate'])/(60*60*24*365))</setvar>
<if{
$GLOBALS['tplvars']['years']}!=="0"then>
<
divclass="years-tagsyearly-tags-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']}YearsofService</div>
</if> 

It might work, it might not. I'm not a wold class programmer

Well apologises that I suck at php dude... and no that code above don't work.

RE: years of service support

#6
if(SHOWRICHEST){
$i = 1;
$players = DB::Query('SELECT * FROM darkrp_player ORDER by wallet desc LIMIT 10');
$html = '<tr>';
foreach($players as $row){
$html = $html.'<td>'.$i.'</td>
<td>'.$row['rpname'].'</td>
<td>$'.formatMoney($row['wallet'], true).'</td>';
if(LEVEL){
$playerlevel = DB::QueryValue('SELECT level FROM darkrp_levels WHERE uid = :uid', array(':uid'=>$row['uid']));
$html = $html.'<td>'.$playerlevel.'</td>';
}
$i++;
$html = $html . '</tr>';
}
}
?>

Heres some code from payable addon on loading screen for garry`s mod. Hope those works!

RE: years of service support

OP
#7
Bumping this, anybody can help please?
I'd appreciate it. Smile

Users browsing this thread: