I had a rethink and came up with the following set of classes to easily handle alternate row colours in tables and elsewhere. The index file will explain everything clearly. You essentially create your own sub-classes that extend the base class, and then call the method.
You can easily add more than two colours. It will then cycle through them all and reset. You may also manually reset for if you need the same alternate row colour template more than once on the same page load.
/* Get the first colour from the template Summer Sunshine as a normal class string */ echo$pRowColours->getSummerSunshine();
/* Get the first colour from the template Grey Scale with "background-color" appended for use in style attributes */ echo$pRowColours->getGreyScaleAsStyle();
/* Reset the template Psychedelic to pointer 0 so the next call will get the first colour again. */ $pRowColours->resetPsychedelic();
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
The Following User Says Thank You to Wildhoney For This Useful Post:
Four classes for rotating background colours in HTML tables/lists? Crazy. Oh and can you not keep zipping up the code snippets (or at least provide an online-viewable version) since downloading just to scan some code seems an awful waste of time and clicks.