Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Row Color

  1. #11
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Heres a quick and simple way.

    CSS:
    Code:
    tr#even { background-color:#C3D9FF; }
    PHP:
    PHP Code:
    <?php
    $tablerow_count
    =0;
    function 
    tablerowswitch() {
    global 
    $tablerow_count;
    $tablerow_count++;
    if (
    $tablerow_count 2) {
    echo 
    "odd";
    }
    else {
    echo 
    "even";
    }
    }
    ?>
    And set the id to this:
    PHP Code:
    id="tablerowswitch()" 
    Ryan
    Sevierville, TN

  2. #12
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by NXArmada View Post
    And set the id to this:
    PHP Code:
    id="tablerowswitch()" 
    That's assuming you are still in the PHP code. If you "escape" your HTML code from your PHP code, you would need to reopen the php tags.

    example:

    Code:
    <?php
      if ($something) {
    ?>
    
    <div id="<?php tablerowswitch(); ?>">
    
    <?php
      }
    ?>
    Otherwise, it would just display the text tablerowswitch() in the id of the div/table.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #13
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Yea well at least you get the idea lol. I should have put that in there for the new users to the PHP section.
    Ryan
    Sevierville, TN

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •