Moron Posted July 18, 2007 Share Posted July 18, 2007 Here's my code: <?php $RESULTMEMBER=mssql_query("select * from MemberInfo MI where BoardName='Youth Advisory Board' order by MI.[LName]"); $RESULTYAB=mssql_fetch_assoc($RESULTMEMBER); $RESULTMEMBERCOUNT=mssql_num_rows($RESULTMEMBER); echo "<CENTER>"; echo "<table width=100% border=0 cellpadding=0 cellspacing=0>"; echo "<TR>"; echo "<TD width=45% align=left valign=top color=green>"; echo "<font size=2 color=#000000 face=arial>"; echo "<b>Member/Address</b>"; echo "</TD>"; echo "<TD width=4% align=left valign=top>"; echo "<font size=2 color=#000000 face=arial>"; echo "<NOBR>"; echo "<b>Grade</b><BR><b>Level</b>"; echo "</NOBR>"; echo "<BR>"; echo "<BR>"; echo "</font>"; echo "</TD>"; echo "<TD align=center valign=top>"; echo "<font size=2 color=#000000 face=arial>"; echo "<b>Telephone</b>"; echo "</font>"; echo "</TD>"; echo "<TD align=right valign=top>"; echo "<font size=2 color=#000000 face=arial>"; echo "<b>Term Expires</b>"; echo "</TD>"; echo "</TR>"; echo "</font>"; echo "</TABLE>"; while ($RESULTYAB = mssql_fetch_assoc($RESULTMEMBER)) { echo "<table width=100% border=0 cellpadding=0 cellspacing=0>"; echo "<TR>"; echo "<TD width=45% align=left valign=top>"; echo "<font size=2 color=#000000 face=arial>"; echo $RESULTYAB['FName']; echo " "; echo $RESULTYAB['MName']; echo " "; echo $RESULTYAB['LName']; echo " "; echo "<font size=1 color=#000000 face=times new roman>"; echo "<NOBR>"; echo "<i>"; echo $RESULTYAB['Appointed']; echo "</i>"; echo "</NOBR>"; echo "</font>"; echo "<font size=2 color=#000000 face=arial>"; echo "<BR>"; echo "<NOBR>"; echo $RESULTYAB['Address']; echo "</NOBR>"; echo "<BR>"; echo "<BR>"; echo "</font>"; echo "</TD>"; echo "<TD width=4% align=right valign=top>"; echo "<font size=2 color=#000000 face=arial>"; echo $RESULTYAB['GradeLevel']; echo "</font>"; echo "</TD>"; echo "<TD align=right valign=top>"; echo "<font size=2 color=#000000 face=arial>"; echo $RESULTYAB['HomePhone']; echo "</font>"; echo "</TD>"; echo "</TD>"; echo "<TD align=right valign=top>"; echo "<font size=2 color=#000000 face=arial>"; $date = date("F j, Y", strtotime($RESULTYAB['TermExpires'])); echo $date; echo "</TD>"; echo "</TR>"; echo "</font>"; echo "</TABLE>"; echo "</CENTER>"; } ?> And here's a screenshot of what it produces (except with real names, addresses, phone numbers): So the crazy question is: is there a way to color the background of every other row? I can't just use "<tr bgcolor=#??????>" because the rows are generated "while" data records are being listed. I want to make it color every other row for ease of visualization. What do you think? Quote Link to comment Share on other sites More sharing options...
trq Posted July 18, 2007 Share Posted July 18, 2007 Ive already solved this issue once today. Read here. Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 18, 2007 Share Posted July 18, 2007 this goes after your query: $css_class = ($css_class=='row_style_1') ? 'row_style_2' : 'row_style_1'; this goes in the tr: <tr class=\"$css_class\"> here is the css: .row_style_1, td.row_style_1 { background-color: #eaeaea; } .row_style_2, td.row_style_2 { background-color: #ffffff; } thanks to whoever's code this is, it helped me Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 19, 2007 Share Posted July 19, 2007 use a counter ($i) and then on the echo of the row say <?php if($i%2=0){echo "<tr bgcolor=\"yellow\">";} else{echo"<tr>"; ?> Quote Link to comment Share on other sites More sharing options...
Moron Posted July 19, 2007 Author Share Posted July 19, 2007 Ive already solved this issue once today. Read here. Perfect! That did the trick. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.