Jump to content

Multiple alternative color row


duncan121

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
Link to comment
https://forums.phpfreaks.com/topic/6755-multiple-alternative-color-row/
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]
[!--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

Archived

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

×
×
  • Create New...

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.