how to change numbers in fpdf cell to red or blue in php

Hi guys, can you please help? I am trying to create a report card in fpdf and want all grades less then 69 to display in red. i have succeeded in creating the database and also fetching the grades in the table i created in fpdf. i try to pass the variable in an this html tag, some thing like this: $fave3 = "<style color:'red'>".$fave5."</style>"; and also pass the $fave3 variable in the table, but it not working. the color does not change to red, infact it displays the entire html tag in the table. please see my code attach:

if(!empty($acada)){
	
	
/* function show_color($id){
	return $id;

} */
	
	
include('schconfigure.php');
$ave = '';
$fave = '';
$ses_sql = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='1st period' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
   
   $sgrade= $row['grade'];
   
 $ses_sql1 = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='2nd period' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row1 = mysqli_fetch_array($ses_sql1,MYSQLI_ASSOC);
   
   $sgrade1= $row1['grade'];
  
   $ses_sql2 = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='3rd period' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row2 = mysqli_fetch_array($ses_sql2,MYSQLI_ASSOC);
   
   $sgrade2= $row2['grade'];
    
	$ses_sql3 = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='3rd period exam' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row3 = mysqli_fetch_array($ses_sql3,MYSQLI_ASSOC);
   
   $sgrade3= $row3['grade'];
   $ses_sql4 = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='4th period' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row4 = mysqli_fetch_array($ses_sql4,MYSQLI_ASSOC);
   
   $sgrade4= $row4['grade'];
	
 $ses_sql5 = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='5th period' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row5 = mysqli_fetch_array($ses_sql5,MYSQLI_ASSOC);
   
   $sgrade5= $row5['grade'];
   
 
   $ses_sql6 = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='6th period' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row6 = mysqli_fetch_array($ses_sql6,MYSQLI_ASSOC);
   
   $sgrade6= $row6['grade'];
   
    $ses_sql7 = mysqli_query($mysqli,"select * from stugrade where subject_id = '1' AND period='6th period exam' and Acadamicyear='$acada' AND student_id='".$_GET["print"]."'");
 $row7 = mysqli_fetch_array($ses_sql7,MYSQLI_ASSOC);
   
   $sgrade7= $row7['grade'];
	 
	 $ave = $sgrade + $sgrade1 + $sgrade2;   	
	 $ave2 = $ave / 3;
	 $fave = $ave2 + $sgrade3;
	 $fave2 = $fave / 2;
     $fave5 = "<style color:'red'>".$fave2."</style>";
	 $fave3 = round($fave5 , 1, PHP_ROUND_HALF_UP);
	 
	// $fave3='B'$fave3;
	 
	  //echo "<p>Hello $name!</p>";
	 
$pdf = new PDF( 'P', 'mm', 'A4' );
$pdf->AddPage();
$pdf->Image('img/nphi.PNG',1,6,70,31,'PNG','www.nationalphil.com');
$pdf->SetFont('Arial','',8);
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->SetFont('Arial','',20);
$pdf->Ln();
$pdf->writeHtml("                                  <b>Soul clinic Public School</b>");
$pdf->SetFont('Arial','i',10);
$pdf->Ln();
$pdf->Ln();
$pdf->writeHtml("                                                                               Paynesville Soul clinic");
$pdf->Ln();
$pdf->writeHtml("                                                                                Monrovia, Liberia");
$pdf->Ln();
$pdf->Ln();
//$pdf->writeHtml("                                                                      <b><u>Report on Work</u></b>");
$pdf->Ln();
$pdf->SetFont('Arial','i',9);
$pdf->writeHtml("<b>Student Name:</b>");
$pdf->Ln();
$pdf->Ln();

$pdf->SetWidths(array(20,15,15,15,15,15,15,15,15,15,15,15,15));
srand(microtime()*1000000);
//$pdf-> $html("myname");
$pdf->SetFont('times','B',7);
$pdf->Row(array("Subject","1st period","2nd period","3rd period","Exam","Average","4th period","5th period","6th period","Exam","Average","Yearly Average"));

 
		 
			 
            $pdf->Cell(20,7,"Math",1,0);
			$pdf->Cell(15,7,"$sgrade",1,0);
            $pdf->Cell(15,7,"$sgrade1",1,0);
			$pdf->Cell(15,7,"$sgrade2",1,0);
			$pdf->Cell(15,7,"$sgrade3",1,0);
			$pdf->Cell(15,7,"$fave3",1,0);
			$pdf->Cell(15,7,"$sgrade4",1,0);
			$pdf->Cell(15,7,"$sgrade5",1,0);
			$pdf->Cell(15,7,"$sgrade6",1,0);
			$pdf->Cell(15,7,"$sgrade7",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
            $pdf->Cell(20,7,"Phonic",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1); 
			$pdf->Cell(20,7,"English",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
            $pdf->Cell(20,7,"Science",1,0);			
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
			$pdf->Cell(20,7,"Social Studies",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
			$pdf->Cell(20,7,"Frensh",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
			$pdf->Cell(20,7,"History",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
			$pdf->Cell(20,7,"Biology",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
			$pdf->Cell(20,7,"Chemistry",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
			$pdf->Cell(15,7,"",1,0);
            $pdf->Cell(15,7,"",1,1);
			
				
	/* $pdf->SetFont('times','B',11);
	$pdf->Row(array("Total Amount","","","","","","","",'$'.$total_amount.'.'.'00')); */
	 $pdf->Ln();
	 $pdf->Output();
}else{
	
	$yearerror = "select acadamy year";
}

 }

Open in new window

Moses DwanaAsked:
Who is Participating?
 
NerdsOfTechTechnology ScientistCommented:
if ($fave3 >= 69){ $pdf->SetTextColor(255,0,0); // red }
$pdf->Cell(15,7,"$fave3",1,0);
if ($fave3 >= 69){ $pdf->SetTextColor(0,0,0); // from red to black }

Open in new window

0
 
Moses DwanaAuthor Commented:
thank ever so mush!!!!!!!!!!!!!!!!!!!!!!!!!!!! it works
0
 
NerdsOfTechTechnology ScientistCommented:
Thank you for your feedback. Please choose my solution #a42461620 above as 'best solution' to close out this question.
0
 
NerdsOfTechTechnology ScientistCommented:
OP acknowledged working solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.