this is my code for a multiplication table. By combining PHP and HTML/CSS I need to make every alternating rows background color white or grey.
I've thought of using a row and using %2==1 and %2==0 to figure out the odd and even rows but how would i target those rows to make a id or class to target on my css file?
Where would I insert this code at?
<?php
echo '<table>';
echo '<tr><th></th>';
for ($x = 1; $x <= 9; $x++)
echo '<th>'.$x.'</th>';
echo '</tr>';
for ($y = 1; $y <= 9; $y++)
{
echo '<tr><th>'.$y.'</th>';
for ($z = 1; $z <= 9; $z++)
{
echo '<td>'.($y * $z).'</td>';
}
echo '</tr>';
}
echo '</table>';
?>
td:nth-child(even) { background: #f5f5f5 } td:nth-child(odd) { background: #ddd }