I am creating a semester map for studnets. If a course is being taken, the cell color should be yellow. If the course is taken, should be green. If the course is not yet taken, cell color will be red.
I am testing student with id '1', in the table 'course_status' there is a column called 'course_status' with "pending", "in_progress", and "done" only.
$sql = "SELECT * FROM course_status WHERE student_id = 1";
$retval = mysqli_query( $link, $sql );
$row=mysqli_fetch_array($retval);
if($row['course_status']== 'done') {$status_color = "green";}
if($row['course_status']== 'in_progress') {$status_color= "yellow";}
if($row['course_status']== 'pending') {$status_color= "red";}
<td style="background-color: <?php echo $status_color; ?>;">CSCI 185
<td style="background-color: <?php echo $status_color; ?>;">CSCI 385
<td style="background-color: <?php echo $status_color; ?>;">CSCI 485
All of the cell have a background color of green despite the student have not yet taken CSCI 385&485. I just want CSCI 185 to have a green background since its taken already.