djtiger76 Posted April 4, 2020 Report Posted April 4, 2020 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> Quote
web541 Posted April 4, 2020 Report Posted April 4, 2020 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> Quote
djtiger76 Posted April 4, 2020 Author Report Posted April 4, 2020 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 Quote
web541 Posted April 4, 2020 Report Posted April 4, 2020 (edited) 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> Edited April 4, 2020 by web541 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.