[thelist] simple! PHP data display
Jay Blanchard
jay.blanchard at niicommunications.com
Thu Aug 22 08:08:01 CDT 2002
[snip]
What I want to do is present is in a single row (alternating colours), at
the
moment it just comes out in one mess, even if someone can point me to a
tutorial
that would be great
<?php
echo $row["field1"];
echo "<BR>";
echo $row["field2"];
echo "<BR>";
echo $row["field3"];
echo "<BR>";
echo $row["field4"];
?>
<?php
} // End of while loop
?>
[/snip]
$rowcount = 0;
while($row = mysql_fetch_object($db)){
//change the color of alternating rows
$rowcount ++;
if ($rowcount == 1){
print("<tr bgcolor=\"#FFFFCC\">\n");
}
elseif ($rowcount <> 1) {
print("<tr>\n");
$rowcount = 0;
}
print("<td>" . $row["field1"] . "</td>\n");
print("<td>" . $row["field2"] . "</td>\n");
print("<td>" . $row["field3"] . "</td>\n");
print("<td>" . $row["field4"] . "</td>\n");
print("</tr>\n");
}
There is also a two line way of alternating row colors with the modulus
operator, but I don't remeber it right off-hand. I also mixed syntax in
above to rapidly reply, you can fix it with no problem though.
HTH!
Jay
"It's hip to snip!"
***********************************************************
* Texas PHP Developers Conf Spring 2003 *
* T Bar M Resort & Conference Center *
* New Braunfels, Texas *
* San Antonio Area PHP Developers Group *
* Interested? Contact jay.blanchard at niicommunications.com *
***********************************************************
More information about the thelist
mailing list