Jump to content

Archived

This topic is now archived and is closed to further replies.

duncan121

Multiple alternative color row

Recommended Posts

I have an alternative color row problem.
I am quite familiar with the normal alternative color rows.
But I have multiple rows with same user so I wanted to highlight all the same users in the same color.

Please the example below.

Mr Smith = yellow
Mr Smith = yellow
Mr Smith = yellow
Mr West = red
Mr West = red
Mr White = yellow
Mr White = yellow
And so on….


Any help would be warmly appreciated

Share this post


Link to post
Share on other sites
[code]
$bgcolor ="yellow";
$lastname = "";

while ($row={fetching array information}){
   if($row[name] != $lastname){
        $lastname=$row[name];
        $bgcolor = ($bgcolor=="yellow")?"red":"yellow";
   }

   // bg color will always alter on a name change
    echo $bgcolor;
}

[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=362331:date=Apr 6 2006, 07:23 PM:name=lead2gold)--][div class=\'quotetop\']QUOTE(lead2gold @ Apr 6 2006, 07:23 PM) [snapback]362331[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
$bgcolor ="yellow";
$lastname = "";

while ($row={fetching array information}){
   if($row[name] != $lastname){
        $lastname=$row[name];
        $bgcolor = ($bgcolor=="yellow")?"red":"yellow";
   }

   // bg color will always alter on a name change
    echo $bgcolor;
}

[/code]
[/quote]


Works a treat...


Thanks

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.