Steve Marquez wrote:
Greetings,

I am attempting to alternate the colors of the container DIV. Anyone know
how to do this?
Thank you very much,

--
Steve M.


<?php

$rowColors = array('#EEEEEE', '#DDDDDD');

$study_title = nl2br(stripslashes($study_title));

$counter = 0;

if ( $result ) {
        while ( $row = mysql_fetch_assoc($result) ) {

                $rowColor = $rowColors[(($counter++) % count($rowColors))];

                echo <<<ROW

<div id="e_options_container" style="background-color:{$rowColor};">
        <div id="e_options" style="width: 100px; ">{$row['optone']}</div>
        <div id="e_options" style="width: 50px; "><a
                href="{$row['edit_item']}"
                >Edit</a></div>
        <div id="e_options" style="width: 50px; "><a
                href="{$row['delete_item']}"
                onclick="return confirm('Are you sure you want to delete?')"
                >Delete</a>
        </div>
        <div id="e_options" style="width: 250px;">{$study_title}</div>
        <div id="e_options" style="width: 75px; ">{$row['date']}</div>
</div>

ROW;

        }
}

?>

in the $rowColors array, you can have as many row colors as you like. I usually use 2 - 4 colors in my row setup. But, using the line that starts with $rowColor = ... makes it simple to update your colors. Just add or remove a color entry and it will automatically take care of it.

is the $study_title variable coming out of the mysql_fetch_array() call, or is it set somewhere above this code? The reason I ask is that you are cleaning it up, outside of your while statement, but, it wasn't clear if with the extract() call you might have been stomping over it.

Two comments about your HTML:
ID in an HTML element is suppose to be unique for the entire page. If you are using the ID as a pointer for some CSS, switch it to a class tag instead.

        <div class="e_option">...</div>

        <style>
        .e_option {
                ...
        }
        </style>

        Same goes for #e_options_container

Why are you using DIV's to display tabular data? Some say that tables should never be used, but IMO, you should be using tables for this. They were designed specifically for displaying tabular data.


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to