- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hey!
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.
Thanks guys!
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:
‘ . $bar . ‘ |
‘;
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.