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
edawson003
Forum Contributor
Posts: 133 Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA
Post
by edawson003 » Fri Oct 09, 2009 8:29 pm
Trying to change a table's <td> with a conditional php statement. This didn't work any thoughts?
Code: Select all
<td width=10><img src="../images/spacer10.gif" width="10" height="10[color=#0000FF]"><?
if(($weightdisplay - $weightdisplay2) < 0) {
$weighttbl = "#ECA98E";
}
?>[/color] </td>
<td width=411 align=center bgcolor[color=#0000FF]="<?php echo $weighttbl; ?>" />[/color]
JNettles
Forum Contributor
Posts: 228 Joined: Mon Oct 05, 2009 4:09 pm
Post
by JNettles » Fri Oct 09, 2009 9:00 pm
What are the values for $weightdisplay and $weightdisplay2? Because if they're greater than 0........... then your echo won't produce anything.
edawson003
Forum Contributor
Posts: 133 Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA
Post
by edawson003 » Fri Oct 09, 2009 9:37 pm
No, there's actually, a lot more to it. Plus, I found a round about way to change the color with the cell. Probably not the best way to implement. Quick and nasty, but it works.
Code: Select all
<?
if(($weightdisplay - $weightdisplay2) < 0) {
echo "<TABLE width=411 bgcolor=#9EDF94><tr><td align=center>";
echo "<span class=pgreen>MESSAGE 1 ";
echo round(((($weightdisplay) - ($weightdisplay2))*-1),1);
echo " </span></td></tr></TABLE>";
}
elseif(($weightdisplay - $weightdisplay2) > 0 && $weightdisplay2 != NULL) {
echo "<TABLE width=411 bgcolor=#FF8585><tr><td align=center>";
echo "<p>MESSAGE 2 ";
echo round((($weightdisplay) - ($weightdisplay2)),1);
echo " </span></td></tr></TABLE>";
}
elseif(($weightdisplay - $weightdisplay2) == 0 && $weightdisplay != NULL && $weightdisplay2 != NULL) {
echo "<TABLE width=411 bgcolor=#E9E9E9><tr><td align=center>";
echo "<p>MESSAGE 3</p>";
echo "</td></tr></TABLE>";
}
elseif($weightdisplay == NULL || $weightdisplay2 == NULL) {
echo "<TABLE width=411 bgcolor=#ABABAB><tr><td align=center bgcolor=#FFFFFF>";
echo "<p>MESSAGE 4</p>";
echo "</td></tr></TABLE>";
}
?>
All that is nested with a <td width=411> of another table. Liek I said, it works!
Griven
Forum Contributor
Posts: 165 Joined: Sat May 09, 2009 8:23 pm
Post
by Griven » Fri Oct 09, 2009 9:43 pm
Are you just trying to alternate the row colors of the table?
edawson003
Forum Contributor
Posts: 133 Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA
Post
by edawson003 » Sat Oct 10, 2009 12:49 am
No, not in this instance; however, I am interested in being able to do that for another part of my site.