Alternate Row Colors



Hire Us!Download Video(0)Comments
Need Jobs done? Use our brand new Jobs Board to get your projects done at affordable prices.


This tutorial will teach you how to use PHP to alternate row colors. This can be applied to any loop.

Example:
0http://www.westernstudios.net
1http://www.westernstudios.net
2http://www.westernstudios.net
3http://www.westernstudios.net
4http://www.westernstudios.net



Steps :
1. This is a very simple bit of code but the results will be easier for the user to understand. The following codes does the trick. The key is the ($i % 2). That code is used to see if there are any remainders which will inturn determine if the number is odd or even.

As you can see we displayed the color using CSS. You can choose to display the color using the bgcolor row tag but for better coding, this method is best.

 

Consider buying me coffee if you find this tutorial helpful.


Hire Us!Download Video(0)Comments
Need Jobs done? Use our brand new Jobs Board to get your projects done at affordable prices.