Total hours to Next Rank - Code request

Hi all.
I have a section on the front page of my crew center that gives a snapshot of how many hours are left before the pilot reaches the next rank.
The problem… When the pilot maxes out it starts to give a negative number. 

 

I would like to add an “if” statement to the following code that says basically, if the hours = < 0, then display “Congratulations<br>You have reached the highest rank.”

 

<div class=“small-box bg-blue”>
                <div class=“inner”>
                    <h3><?php echo ($nextrank->minhours - $pilot_hours)?> Hours</h3>

                    <p>until promotion to<br>
                    <?php echo $nextrank->rank?>!</p>
                </div>
                <div class=“icon”>
                    <i class=“ion ion-checkmark”></i>
                </div>
            </div>

Try this:

\<div class="small-box bg-blue"\> \<div class="inner"\> \<?php $hours = ($nextrank-\>minhours - $pilot\_hours); if ($hours \< 0) { echo '\<h3\>Congratulations \<br\> You have reached the highest rank.\</h3\>'; } else { echo '\<h3\>'.$hours.' Hours\</h3\>'; echo '\<p\>until promotion to \<br\> '.$nextrank-\>rank.'!\</p\>'; ?\> \</div\> \<div class="icon"\> \<i class="ion ion-checkmark"\>\</i\> \</div\> \</div\>

 

Giving me a parse error: 
Parse error: syntax error, unexpected end of file in /home/tstamer/public_html/dev/lib/skins/crewcenter/profile_main.php 

Oops forgot to close the bracket

Try this:

\<div class="small-box bg-blue"\> \<div class="inner"\> \<?php $hours = ($nextrank-\>minhours - $pilot\_hours); if ($hours \< 0) { echo '\<h3\>Congratulations \<br\> You have reached the highest rank.\</h3\>'; } else { echo '\<h3\>'.$hours.' Hours\</h3\>'; echo '\<p\>until promotion to \<br\> '.$nextrank-\>rank.'!\</p\>'; } ?\> \</div\> \<div class="icon"\> \<i class="ion ion-checkmark"\>\</i\> \</div\> \</div\>

 

1 Like

That works. Thanks!