mercredi 30 septembre 2015

I have a PHP table that calculates Fahrenheit into Celsius, I need to use Span Class to change color of the Celsius results based on certain criteria

How can I go about doing this? I know I have to use an if statement, but I have tried placing it everywhere and my code just gets messed up.

The criteria is if the value in C is less than or equal to 0, the result should be blue. If it is greater than or equal to 100 C, it's displayed in red. All other temperatures in C should be green.

This is my table code,

<tr>
        <td align="center"><strong>Fahrenheit</strong></td>
        <td align="center"><strong>Celsius</strong></td>
    </tr>

   <?php

   for ($tempFahrenheit = 0; $tempFahrenheit <= 250; $tempFahrenheit++){
   $tempCelsius = (5/9)*($tempFahrenheit-32);
   echo "<tr><td>$tempFahrenheit&degF.</td>";
   echo "<td>$tempCelsius&degC.</td></tr>";   

  }

  ?>

Aucun commentaire:

Enregistrer un commentaire