I would like to find a function that alternates a table’s row colors in PHP. I used to have one but I can’t find the file anymore.
Even included a table header spot if you want.
table-heading – Styles for the table header.
odd – Styles for the odd rows.
even – Styles for the even rows.
You could consider using the jquery solution suggested by noahgelman. if you really want / need a php solution it depends on the source of your table-data. if you are iterating over the data (like an array) the solution could be:
What about nth child(even)?
EDIT: I suppose if you wanted a PHP solution (dirtying your markup!) you could do something like:
Fill that in with your other stuff too (database reads and writes and such) but there’s your basic structure.
Although I still like the purely CSS solution better.
there are snippets for a solution in both jQuery and PHP
You must be logged in to reply to this topic.