I'm having trouble figuring out how to alternate a table row color within the output created by a foreach statement.
I've done it before using a while loop, but that methodology doesn't seem to work here.
I did a search on the forums and couldn't find an example using a foreach statement.
Thanks in advance for any help!
print "<table border=0 cellspacing=0 cellpadding=6 width=550 class=tline>";
foreach($articles as $article){
$images=$imageMgr->getImageArray($article['ID']);
$f=$fileMgr->getFileArray($article['ID']);
print "<tr bgcolor=\"$bgcolor\"><td valign=top class='bline'>";
print "<h4>".htmlentities($article['Title'])."</h4>";
if(isset($f[1]['original_name'])){
$img="<img src=\"".$fileMgr->getIconURL($f[1]['extension'])."\" border='0' alt='' class='vmiddle'>";
print "<div style='padding:4px 0px 4px 0px;'><i>Download File: ";
print $fileMgr->getDownloadUrl($article['ID'],1,$img).' ';
print $fileMgr->getDownloadUrl($article['ID'],1,htmlentities($f[1]['original_name']));
print "</i></div>";
}
print nl2br(htmlentities($article['Story']));
print "<div style='padding-top:5px;font-size:9pt;color:#666666'><i>Posted On ";
if(!empty($article['Release']))
print date('F j, Y',strtotime($article['Release']));
if(!empty($article['Source']))
print " - Source/Credit: ".htmlentities($article['Source']);
print "</i></div>";
print "</td>";
if(isset($images[1]['full']) && file_exists($images[1]['full'])){
print "<td align=center class='bline'>";
print "<img src='{$images[1]['full']}' border=0 alt='' style='margin-left:5px;'></td>";
} else {
print "<td class='bline'> </td>";
}
print "</tr>";
}
print "</table>";