Reputation: 11
I am no coder but am trying to take anything CSS related out of a php file but require a little help.
How can I re write the below code to get the bgcolor from an external CSS instead of the php doing the job
I just want the bellow rewriting to include the CSS class instead of the code actualy making the color.
Hope you understand what I am saying
first bit of code
$bgcolour = ($k % 2) ? 'bgcolor="#FFFEEE"' : '';
Second bit of code
'ROWCOLOUR' => ($row['highlighted'] == 'y') ? 'bgcolor="#fea100"' : $bgcolour,
Upvotes: 0
Views: 95
Reputation: 774
<style>
.mouseoverbg{
background-color : #eeefff;
}
.oddrowbg{
background-color : #fffeee;
}
.evenrowbg{
background-color : #fea100;
}
</style>
<table>
<?php
$ni = 5;
for($i=0 ; $i<$ni; $i++)
{
$bgcolor = ($i%2)?"evenrowbg" : "oddrowbg";
?>
<tr onmouseover="this.className='mouseoverbg'" onmouseout="this.className='<?php echo $bgcolor?>'" class="<?php echo $bgcolor?>">
<td><?php echo $i;?></td>
</tr>
<?php
}?>
</table>
Try this code it may help you.
Upvotes: 0
Reputation: 24276
CSS:
.fffeee {
background-color: #FFFEEE;
}
.fea100 {
background-color: #FEA100;
}
PHP:
$cssClass = ($k % 2 == 0 && $row['highlighted'] != 'y') ? 'fffeee' : 'fea100';
'ROWCOLOUR' => 'class="' . $cssClass . '"',
Upvotes: 1