Page 1 of 1

[Solved] Is this written ok?

Posted: Tue Aug 16, 2005 3:14 pm
by Addos
I wonder if there is a better way of doing this.

Code: Select all

$output_value1 = "ticked";
<td 
 <?PHP if ($output_value1 == "ticked") { ?>
class="calendar">1 <? } else {?> >1 </td> <? }?>
I want a table cell to be one of two possible colours and although the code above works I’m not sure if it’s properly written. I have given the main table on the page the colour grey so that all I need to do is change the colour of the cell once.
Thanks for any advice.
B

Code: Select all

Css

.calendar {
	background-color: #FFCC00;
}
.calendartablebackground {
	background-color: #CCCCCC;
}

Posted: Tue Aug 16, 2005 3:21 pm
by hawleyjr

Code: Select all

$output_value1 = "ticked";

echo '<td' . ($output_value1 == 'ticked'? ' class="calendar"':'') . '>1</td>';

Posted: Tue Aug 16, 2005 3:29 pm
by Addos
Thank you so much. I just wish I could think this way!

:wink: