Web Analytics Made Easy -
StatCounter Having trouble alternating row colors - CodingForum

Announcement

Collapse
No announcement yet.

Having trouble alternating row colors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Having trouble alternating row colors

    I cant figure out why it isnt working.

    I put I think all the correct things.

    Here is how it looks:

    PHP Code:
    <?php

    //alternating row colors
    $color1 "#CCFFCC"
    $color2 "#BFD8BC"
    $i 1;

    while(
    $rows=mysql_fetch_array($result)){
        
        
    if(
    $i%== 1) {
    $color $color1; }
    else { 
    $color $color2; }

    ?>
    <tr>
    <td align="center" bgcolor="<?php echo $color?>"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
    But for some reason its showing the same color for all the rows.

    Preview: http://brian.ubietymedia.com/project/

    You can see that the first row is the same color instead of alternating green and red.

    If the whole script is needed, il be glad to post it.

    MY MSN: [email protected]
    PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
    PM me anytime for HTML, PHP or web design help. I will be glad to help you out.

  • #2
    You are not incrementing $i. Change that to if ($i++ % 2 == 1), and you should see the alternating rows.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎