Using simple PHP alternating color code buy rows ALLWAYS GREEN

This is a discussion on Using simple PHP alternating color code buy rows ALLWAYS GREEN within the PHP General forums, part of the PHP Programming Forums category; I am using a super simple PHP alternating row color code by my rows are always coming out green. The ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-13-2004
Rich
 
Posts: n/a
Default Using simple PHP alternating color code buy rows ALLWAYS GREEN

I am using a super simple PHP alternating row color code by my rows
are always coming out green. The code is really simple. the value
for i is set to zero then each time a row is written the value
$bgcolorvar is reset to either yellow or blue. The back ground color
for that line is then set to the variable bgcolorvar. The problem is
each line displays green. To verify I coded this right I even put in
the command to echo the value of bgcolorvar in the first cell of each
line. And sure enough it flips between writing blue or yellow in each
cell. To confirm that I didnt goof up something else I manually set
bgcolor="blue" on the line where I have it set to
bgcolor="$bgcolorvar" and sure enough it turned blue.

The only way I can get it to change colors is to give the variable a
new name of a differnt length. Sometimes when I do that ALL the rows
turn to magenta. The real kicker is I tried 3 or 4 differnt scripts
for alterntating line color and everyone did the same thing.

I am running this on apache 1.39 (I think, well it is the 1.XX version
of apache) with the latest non-beta release of php.

Any idea what I am doing wrong?




<table border="1" cellspacing="0" cellpadding="0">

<tr bgcolor="#003366" class="tableheader">
<td ><div align="center" class="style1">Name</div></td>
</tr>

<?php $i = 0; ?>

<?php do { ?>
<?php $bgcolorvar = ($i++ & 1) ? 'yellow' : 'blue'; ?>


<tr bgcolor="$bgcolorvar">

<td ><div align="center"><?php echo $bgcolorvar ?><?php echo
$row_rsPayments['item_name']; ?>&nbsp;</div></td>
<td>

<?php } while ($row_rsPayments = mysql_fetch_assoc($rsPayments)); ?>
</table>
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:14 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0