I am performing some server side validations and I want to style the rows depending on the PHP variable. For example, if PHP variable is 2 the row should be styled to green else red.
I was thinking to add a php function in the html but it doesn't work. What is the best practice to accomplish that?
<tr class="<?php add_red();?>">
<td>
<input class="w3-radio" name="reflexive" type="radio" id="reflexiveYES" value="yes">
</td>
</tr>
function add_red(){
//inside validation.php
if($a == 2){
return "w3-green"; //class for changing the background
}
return "w3-red";
}
w3-greenandw3-redare CSS classes...<input class="w3-radio <?= $a == 2 ? "w3-green" : "w3-red"; ?>" name="reflexive" type="radio" id="reflexiveYES" value="yes" />foreach()loop there's probably a bigger problem overall ;)