Jump to content

greater than less than question...


cowboysdude

Recommended Posts

I'm working on this module and so far so good BUT I would like to be able to highlight the higher score and for some reason I'm having an issue with it...

 

It's more of an else statement issue...

 

Here is what I have....


if ($game['q'] == 'P') {
?>
<li><div class=box-blue>  <?= $game['d'] ?> | <?= $datey ?> | <?= $game['t'] ?></div>

 <?= $homeTeam ?> <?= $game['hs'] ?> <br />
 <?= $visitingTeam ?> <?= $game['vs'] ?>  <br />
      <div class=box-blue>  Game Temp: <?= $current ?>°   Condition: <?= $condition ?> </div></li>
<?php }
       else { ?>
<li><?= $homeTeam ?>  <?= $game['hs'] ?> <br /><?= $visitingTeam ?> <?= $game['vs'] ?>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php } ?>
  <?php if ($game['q'] == "FO") {?>Final Overtime<?php }?>
  <?php if ($game['q'] == "H") {?>Half Time<?php }?>
  <?php if ($game['q'] == "1") {?>1st Quarter<?php } ?>
  <?php if ($game['q'] == "2") {?>2nd Quarter<?php } ?>
  <?php if ($game['q'] == "3") {?>3rd Quarter<?php } ?>
  <?php if ($game['q'] == "4") {?>4th Quarter<?php } ?>
  <?php if ($game['q'] == "T") {?>Tie<?php }?>
    <?= $game['k'] ?>
       </div></li>
   <?php }

 
 
What I tried to add was this..
   
If( $game['hs'] > $game['vs'] ){ ?> 
<li><?= $homeTeam ?>  <font color=red><?= $game['hs'] ?></font> <br /><?= $visitingTeam ?> <?= $game['vs'] ?>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php } 

  else {?>
 <li><?= $homeTeam ?>  <?= $game['hs'] ?> <br /><?= $visitingTeam ?> <font color=red><?= $game['vs'] ?></font>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php }  

But when I do I get an else error... what am I missing here? I thought this would be pretty easy...

Thank yoU!

Edited by cowboysdude
Link to comment
Share on other sites

What I tried to add was this..

If( $game['hs'] > $game['vs'] ){ ?> 
<li><?= $homeTeam ?>  <font color=red><?= $game['hs'] ?></font> <br /><?= $visitingTeam ?> <?= $game['vs'] ?>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php } 

  else {?>
 <li><?= $homeTeam ?>  <?= $game['hs'] ?> <br /><?= $visitingTeam ?> <font color=red><?= $game['vs'] ?></font>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php }

But when I do I get an else error... what am I missing here?

 

You're missing an open curly bracket before the else. And the else needs to be closed with a curly bracket. You could try something like this:

if( $game['hs'] > $game['vs'] ){
    ?><li><?= $homeTeam ?>  <font color=red><?= $game['hs'] ?></font> <br /><?= $visitingTeam ?> <?= $game['vs'] ?>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php } 
} else {
    ?><li><?= $homeTeam ?>  <?= $game['hs'] ?> <br /><?= $visitingTeam ?> <font color=red><?= $game['vs'] ?></font>  <br />  <div class=box-blue>  <?php if ($game['q'] == "F") {?>Final<?php } 
}
Link to comment
Share on other sites

That is still a mess of duplicate code.

 

DRY: Don't Repeat Yourself.

* Still could be improved.

 

 

<?php
if ($game['hs'] > $game['vs'])
    {
    $home_color    = '<span style="color:red">';
    $visitor_color = '<span>';
    }
else
    {
    $home_color    = '<span>';
    $visitor_color = '<span style="color:red">';
    }
?>
<li>
<?php echo "$homeTeam    $home_color {$game['hs']} </span> <br> $visitingTeam $visitor_color {$game['vs']} </span>";?>
<br>  <div class=box-blue>  </div>
</li>
 
<?php if ($game['q'] == "F") { echo 'Final'; }?>
Edited by benanamen
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.