[Solved] Is this written ok?

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
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

[Solved] Is this written ok?

Post 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;
}
Last edited by Addos on Tue Aug 16, 2005 3:30 pm, edited 1 time in total.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Code: Select all

$output_value1 = "ticked";

echo '<td' . ($output_value1 == 'ticked'? ' class="calendar"':'') . '>1</td>';
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

Thank you so much. I just wish I could think this way!

:wink:
Post Reply