JSFiddle - React, Tailwind, and code Playground
by ason5861_cs
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<?php
$rs_wtp = array(
'name' => array(
'100-1 Sometext',
'233-1 Sometext',
'500 Sometext',
'300 Sometext',
'300 Sometext',
'200 Sometext',
'110-4 Sometext',
'150 Sometext',
'455 Sometext',
'500 Sometext',
'199 Sometext'
)
);
$colors = array (
1 => "blue", //--> for all colors within the range of 100-199
2 => "red", //--> for all colors within the range of 200-299
3 => "yellow", //--> for all colors within the range of 300-399
4 => "purple", //--> for all colors within the range of 400-499
5 => "green" //--> for all colors within the range of 500-599
);
$stmt = 'Rules:<br>
1 => "blue" //--> for all colors within the range of 100-199
2 => "red" //--> for all colors within the range of 200-299
3 => "yellow" //--> for all colors within the range of 300-399
4 => "purple" //--> for all colors within the range of 400-499
5 => "green" //--> for all colors within the range of 500-599
';
foreach($rs_wtp['name'] as $name => $valuetocheck){
$check = $valuetocheck[0];
$stmt .= '<div style="color:';
foreach ($colors as $key => $color){
if($check == $key){
$stmt .= $color;
}
}$stmt .= ';">'.$valuetocheck.'</div>';
}
echo $stmt;
CSS
table{
border:none;
}
td{
border:none;
}
.red_bg{
// background:yellow;
color:red;
}
JavaScript
$(document).ready(function(){
$('table tr').each(function(){
if($(this).children('td:nth-child(1)').text()=='no'){
$(this).addClass('red_bg');
}
});
});