Page 1 of 1
Need Simple way to change backcolor?
Posted: Sun Feb 21, 2010 6:16 pm
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
Re: Need Simple way to change backcolor?
Posted: Sun Feb 21, 2010 6:25 pm
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
Re: Need Simple way to change backcolor?
Posted: Sun Feb 21, 2010 6:27 pm
by gertrudis
Background of body and fonts
Re: Need Simple way to change backcolor?
Posted: Sun Feb 21, 2010 6:52 pm
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
Re: Need Simple way to change backcolor?
Posted: Mon Feb 22, 2010 5:02 am
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.