Brain Fart- table formatting help

From: Date: Mon, 29 Jul 2002 13:19:57 +0000
Subject: Brain Fart- table formatting help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-110161@lists.php.net to get a copy of this message
I'm having a total brain fart and can not seem to get the right logic for this... I'm trying to format the output of a db query with alternating row colors, the thing is the usual if ($i%2) {} will not work here because the alternating colors do not necessarily fall on odd or even rows. The one constant is that if ($row->show_title) is true the table row will have a background color then I need to make the rows after that alternate until if ($row->show_title) is true again. Roughly I have the whole thing laid out like this right now: echo "<table BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\">\n"; while($row = mysql_fetch_object($result)) { if($row->show_company && $row->show_title && $row->show_month) { display month; } else if ($row->show_title) { display title; display first row with background color; } else { display rows with no background color; //right here needs to alternate <tr> background color } } echo "</table>"; I think I've been looking at his too long and I just have jello brain right now but I just can't seem to straighten this out in my head... Thanks for the help... -B

« previous php.general (#110161) next »