#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    44
    Rep Power
    15
    I posted this question in the XML forum about a week ago, but for some reason or another haven't recieved any answer... and I know it's probably just a simple solution I've overlooked.

    I need to be able to dynamically change the color of every other row in a table.

    I've tried 4 different methods and none of them seem to work. Any help is greatly appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    USA
    Posts
    226
    Rep Power
    15
    I just did this with a PHP table created from database input.

    PHP Code:

    <?
    $dbLink = mysql_connect("localhost", "sample", "");

    mysql_select_db("sample", $dbLink);

    $Query = "SELECT ID, DESCRIPTION, CATEGORY, PRICE " . "FROM Feeders ";
    $dbResult = mysql_query($Query, $dbLink);

    $color1 = "#CCCCCC";
    $color2 = "#FFFFFF";
    $color = $color1;

    print("<table border='0' cellspacing='5' cellpadding='0'>");
    print("<form>");
    print("<tr><td><b>Quantity</b></td><td><b>ID</b></td><td><b>Description</b></td><td><b>Cat egory</b></td><td><b>Price</b></td></tr>");

    while($row = mysql_fetch_array($dbResult, MYSQL_ASSOC))
    {
    print("<tr bgcolor=".$color."><td align='center'><input type='text' size='2' name='$row[DESCRIPTION]'></td>" . "<td>" . $row[ID] . "</td>" . "<td>" . $row[DESCRIPTION] . "</td>" . "<td>" . $row[CATEGORY] . "</td>" . "<td>$" . $row[PRICE] . "</td></tr>n");

    if ($color == $color1) {
    $color = $color2;
    }
    else {
    $color = $color1;
    }
    }
    print("</form>");
    print("</table>");
    ?>

    This should work similarly in other langauges. Hope this helps.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    44
    Rep Power
    15
    Thanks for your input.

    XML/XSL is strange though, so I finally got and used a different method.

    Anyone interested can find it in the XML forum.

IMN logo majestic logo threadwatch logo seochat tools logo