Regardless whether you are trying to highlight every other row on a table, or div’s with classes, this script will highlight alternate rows
$count = 0;
while ($i = mysql_fetch_array($result)){
$count++; // increases by one on each iteration of loop
if (is_float($counter/2)){ $class = "grey"; } else{ $class = "white"; }
echo ‘Content’; // either grey or white
// Alternatively
echo ‘Content’; // either grey or white
}
Posted On: Wednesday, May 28th, 2008 @ 5:52 pm by Ian Tearle
If you would like to discuss anything about this post, please be polite and add your comments below.
No HTML is allowed. All links, and new lines will be automagically converted to HTML for you.
Notice to spammers, all links will be sanitized with rel="nofollow".
If you would like to discuss anything about your next project please drop me a line.
Projects start at £99.00 per month
We normally book 2–3 months in advance.
No matter how small your project is, or if the prices above scare you, please do get in touch, I shall always listen and will advise freely alternative ideas or solutions. If you are a charity, let's talk!