Jump to content


Photo

Multiple alternative color row


  • Please log in to reply
2 replies to this topic

#1 duncan121

duncan121
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 April 2006 - 07:17 PM

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

#2 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 06 April 2006 - 07:23 PM

$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;
}



#3 duncan121

duncan121
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 April 2006 - 11:24 PM

[!--quoteo(post=362331:date=Apr 6 2006, 07:23 PM:name=lead2gold)--][div class=\'quotetop\']QUOTE(lead2gold @ Apr 6 2006, 07:23 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$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;
}

[/quote]


Works a treat...


Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users