Need Simple way to change backcolor?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gertrudis
Forum Newbie
Posts: 14
Joined: Wed Jan 27, 2010 8:15 pm

Need Simple way to change backcolor?

Post by gertrudis »

Hi to all.
I'm new to php and I need to know how to change background color basic on condition:
backcg="y"
If (backcg="y")
{background blue}
else
{default background}


thanks in advance
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Need Simple way to change backcolor?

Post by mikosiko »

gertrudis wrote:Hi to all.
I'm new to php and I need to know how to change background color basic on condition:
backcg="y"
If (backcg="y")
{background blue}
else
{default background}


thanks in advance
background colour of what?.... body, table, table row, field, etc, etc... several choices... for me, the easy way is using CSS
gertrudis
Forum Newbie
Posts: 14
Joined: Wed Jan 27, 2010 8:15 pm

Re: Need Simple way to change backcolor?

Post by gertrudis »

Background of body and fonts
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Need Simple way to change backcolor?

Post by mikosiko »

CSS... either using a main container (wrapper) or using different colour schemas...

here you can get an idea
http://www.lateralcode.com/alternate-colors-php/

Miko
wilded1
Forum Newbie
Posts: 9
Joined: Sun Feb 21, 2010 11:49 am

Re: Need Simple way to change backcolor?

Post by wilded1 »

This is something I did for table rows whilst printing an array.
I have two styles in the CSS, .hilite1 and .hilite2:

Code: Select all

 
$hilite = 1;
while ($row = pg_fetch_array($result)) {
 // Jump out of PHP for a while
?>
<tr class="trHiLite<?php echo $hilite;?>">
<td><?php echo $row['zonerp_cs'];?></td>
</tr>
<?php
if ($hilite == 2){
$hilite--;
}
else{
$hilite++;
}
}
 
This was using data from a postgres DB, hence the pg_fetch_array.
Post Reply