samedi 18 novembre 2017

json and php If, else statement

This php code generates a table with some information like: temperature, water health, ph level and other things ...

if (count($auxGateway->getMaquina()) > 0)
{
    foreach($auxGateway->getMaquina() as $maq)
    {
        echo '<div class="cont-maq-uni">';//Cria a div para cada maquina
        echo '  <table class="maq">';//Cria uma tabela
        echo '      <tr>';
        echo '          <td colspan="2">';
        echo '              <h2 class="maq-head">'.$maq->getNome().'</h2>';
        echo '          </td>';
        echo '      </tr>';
        foreach($maq->getVariavel() as $var)
        {
            echo '  <tr class="maq">';
            echo '      <td class="maq">';
            echo '          <p class="n_font maq">'.$var->getNome().'</p>';
            echo '      </td>';
            echo '      <td class="maq">';
            echo '          <p class="n_font maq">'.(floatval($var->getValor()) * floatval($var->getMultiplicador()) + floatval($var->getSomador())).' '.$var->getUnidadeValor().'</p>';
            echo '      </td>';
            echo '  </tr>';
        }
        echo '  </table>';
        echo '</div>'; 
    }
}

so I need to create a code to show some images if that information is bigger or less. For example: if 'temperature' <30 then it will show the image (notgood.jpeg). The problem is: how do I name these values since they are inside the MYSQL database? How will I name each row in the table?

Thank you guys!

Aucun commentaire:

Enregistrer un commentaire