5
How do I make the average result turn red if the value is less than 20?
Follows the code:
<?php
function media($p1,$p2,$p3) {
$resultado = ($p1 + $p2 + $p3)/3;
return $resultado;
}
$aluno[0]["nome"] = "Ryan";
$aluno[0]["media"] = media(10,20,30);
$aluno[1]["nome"] = "Mikhaela";
$aluno[1]["media"] = media(40,50,60);
for($i=0;$i<count($aluno);$i++){
echo "<b> Nome do Aluno </b>".$aluno[$i]["nome"]."<br>";
echo "<b> A media do Aluno e </b>".$aluno[$i]["media"]."<br><br>";
}
?>
I think it would be better to add the span element only in case the note is really red, and not just change the attribute (unless it is an attribute for blue and one for red).
– Bacco
@Bacco, thank you for Suggestão. I prefer it this way, to be consistent. So all values have the same "wrapper" and if it is necessary to select them with javascript it is easier to use the
span
to reach them.– Sergio