I am creating a table full of values dynamically… I was woundering if there is a way to alternate the row color of this table between white and light grey..
this is the code I am using to create the table…
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['width'] . "</td>";
echo "<td>" . $row['height'] . "</td>";
echo "<td>" . $row['normal_fill'] . "</td>";
echo "<td>" . $row['our_fill'] . "</td>";
echo "<td>" . $row['old_price'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo '<td><form method="post" action=""><input type="hidden" name="duckdown_id" value="'.$row['duckdown_id'].'" /><input type="submit" name="sumbit" value="Delete" /></form></td>';
echo "</tr>";
}
echo "</table>";
Add an incremental variable and check every 2’nd row:
As a side note, I see you are still using
mysql_*functions, If you just started you could move toPDOasmysql_*functions are deprecated. Here is a nice tutorial.