I have a database and a table named status. A status of 0 means unread and a status of 1 means read If the status is 0 the individual row is supposed to turn lime. If it is 1 it’s white.
$colors = array("lime", "white");
echo "<style type=\"text/css\">";
echo "tr:hover {";
echo "background: #cc00ff;";
echo "color: white;";
echo "}";
echo "tr {";
echo "font-family: Verdana, Geneva, sans-serif;";
echo "font-size: 13px;";
echo "background: $colors[$status];";
echo "}";
echo "</style>";
the $status variable is set here:
while ($row = mysql_fetch_row($result))
{
echo "<tr>";
//rows for <table>
echo "</tr>";
$status = $row[4];//status table either a 0 or 1
}
However when the table row background is set it changes for all the table rows instead of just the row with a status of 0.
How can I make the individual rows change color depending on their status value?
This code is rendering multiple styles. Something like this
Only the last one would take effect. This is not only wrong terribly inefficient also. Put the styles just once and then use the class in the tr tag when you need. Something like this
then render the appropriate html