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
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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.