How would I go about alternating row colors in a table with PHP? Thanks...
------------------
WebDevHQ.com - The Web Developer Headquarters! HUNDREDS of articles, reviews tools and more!
SitePoint Enthusiast
I just bookmarked this yesterday. Haven't used it yet, but I'm guessing it works:
http://www.faqts.com/knowledge-base/.../aid/783/fid/9
------------------
"Whatever can be said can be said clearly." -- Ludwig Wittgenstein
Seems that one works great for a controlled loop but how you will you know how many records you will have each time, I use this to get the same effect:
$dbrow1 = "#ffffff";
$dbrow2 = "#eeeeee";
$rowcolor = $dbrow1;
while ($myrow = mysql_fetch_array($result)) {
print '<tr bgcolor='. $rowcolor .'>';
print '<td>some data</td>';
print '</tr>'; }
//Change row colors
if ($rowcolor == $dbrow1) {
$rowcolor = $dbrow2;
} else {
$rowcolor = $dbrow1;
}
}
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks