You want your data to appear with different color backgrounds, like the main message list on this board, and the sub message list under any given message?
Well the fourm software used here uses tables which make it easier to do this than what you are doing. But if you don't want to use a table you should use a DIV and some CSS to make it work.
<style>
.blue-row { background-color: blue; }
.white-row { background-color: white; }
</style>
That will set up the CSS that you need then in your while loop you just need to add the <div></div> tags and the code to alternate:
$switch = 0;
while (is_array($row)) {
<b>
$switch++;
if ($switch % 2) {
$class = "blue-row";
}
else {
$class = "white-row";
}
</b>
for(reset($row); $fieldName=key($row); next($row)) {
<b>
if ($switch == 1) {
printf("\n<br>");
}
else {
printf("</div>\n<br>");
}
printf("<div class=\"$class\">";
</b>
if ($fieldName==title){
$fieldValue=$row[$fieldName];
$title=$fieldValue;
}
if ($fieldName==desc){
$fieldValue=$row[$fieldName];
$desc=$fieldValue;
}
if ($fieldName==url) {
$fieldValue=$row[$fieldName];
$url=$fieldValue;
}
<b>
if ($switch) { //found some rows and need to clean up <div></div> block
printf("</div>\n<br>");
</b>