
Originally Posted by
Pieman
I'm assuming you're while loop looks something like this:
PHP Code:
$i = 0;
while ($array = mysql_fetch_array($result) ) {
//Generate comment
$i++;
}
Now I would do something like, if the last digit of $i is a prime number (1,3,5,7,9) change background. So if $i would contain for example 327, it would change the background color because 7 is a prime number. I don't know how you would get the last digit of $i, maybe there's a function for it. But I'm sure you'll figure something out.
http://foxx.fsdesign.cz/fms/article.php?id=16
PHP Code:
$i = 0;
//print 'em all
while ($array = mysql_fetch_array($result) )
{
if(($i % 2) == 0) echo '<div id="commentz"><h3 class="comments">'.stripslashes($array['title']).'</h3>
<p class="small">'.stripslashes($array['comment']).'</p>
<p class="footercom"><b>posted on:</b><i> '.$array['sd'].'</i> | <b>by:</b> <a href="member.php?id='.$autharray['id'].'">'.$array['author'].'</a></p>
</div>';
else
echo '<div id="commentz2"><h3 class="comments">'.stripslashes($array['title']).'</h3>
<p class="small">'.stripslashes($array['comment']).'</p>
<p class="footercom"><b>posted on:</b><i> '.$array['sd'].'</i> | <b>by:</b> <a href="member.php?id='.$autharray['id'].'">'.$array['author'].'</a></p>
</div>';
$i++;
}