PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi there- Question for you. I have a simple for loop that writes table data to a web page. What I would like to do is group some of the data by similarity and alter the background color for each group. For visual instance:
2010
2010
2010 2009
2009 2008
2008
2008
I'm wondering if I need to push each group into an array, and then change the color of the even numbered indices. How might I push those groups into an array? Thanks any help is appreciated!
Each fetch is from an array, to begin with, so there's no reason to create another one. The details depend on whether you want specific colors for specific groups or whether you just want to alternate colors to highlight the changes, for which what you have is almost enough. However, I would advise against using "short tags" in PHP. It isn't portable to all servers. Always use <?php and echo.
Thanks for the quick reply! So displaying an alternative color to highlight the changes is all that is necessary. In other words, every other group can be the same color. How might I do that? Any additional help is appreciated. Thanks!