I have the following code, which creates a dynamic table with a dynamic thead and tbody, with data coming from a pivot table in MySQL, but displayed via php:
while($row = $res->fetch_row()) { echo "<tr>"; foreach($row as $cell) { // dd($row); if ($cell === NULL) { $cell = '-'; } echo "<td>$cell</td>"; } echo "</tr>\n"; }
I want to be able to return a specific value. For example, the currently returned result is:
suject | Fraction | Comment |
---|---|---|
English language | 43 | a good job |
English Literature | 59 | good |
But when the student gets 50%, I want to mark the score as red through php, how can I achieve this function in the $cell variable?
Add a class to the row using a
if
statement and use CSS to display it red.