Alternate rows in a table with different formatting possible with PHP table?

Hi,

If I use PHP to design a HTML table I only use the PHP to design one row and then the row repeats to create the table from the data from the MySQL database.

This is a quick way of designing a table using PHP content from MySQL database but the problem is I want each row in the table to be alternate colours to make it look better. Is this possible? PHP only requires one line of the table to repeat. Can you write code to say alternate the colour of the rows?

Thanks,

Matt.

sure possible with CSS (:nth-child())

i’ve looked it up - it looks like i could use something like:

:nth-child(odd) {
    background: #ff0000;
}

thanks

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.