PHP Auto-highlight cell depending on data from database -
good day! working on php application , stumbled upon problem on auto-highlighting.. want ask how auto-highlight cell of table, data came database, after checking if value negative, 0, or positive. red negative. yellow 0 , green positive.
please note have no experience regarding javascript or ajax , rudimentary knowledge on css. thank you.
if needed, can post part of code here.
thank you.
it might helpful you:
function getsamplestatus($sampleid){ if($sampleid==1){ $color="#007334"; }elseif($sampleid==2){ $color="#3f96e8"; }elseif($sampleid==3){ $color="#ff9900"; }elseif($sampleid==4){ $color="#ff9770"; } else{ $color="#ff0000"; } $query='select status config status_id='.$sampleid; $this->_db->setquery( $query ); $status =$this->_db->loadresult(); return "<span style='color:".$color.";padding-left:200px;'>".$status."</span>"; }
this function adds different colors depending on sample status.
for example:
- for disapproved records, color red.
- for approved records, color green.
- for lab completed records, color yellow , on..
edit:
for simplicity, try this:
$yourdatafromdatabase = 3; //which either -ve, 0 or positive if($yourdatafromdatabase < 0){ $color="#ff0000"; //red less 0 }elseif($yourdatafromdatabase== 0){ $color="#ffff00"; //yellow 0 } else{ $color="#00ff00"; //green positive } echo "<span style=\"color: $color\"> <h1> wow color! </h1></span>"; ?>
Comments
Post a Comment