Jump to content

If Else Ans Elseif In A Table


podarum

Recommended Posts

Hi,I have a table format, and I'm trying to insert an if / else statement in one of the table's cells (where I currently have 'Content1'.Here's my example (below). I'd like insert an if $Score>300 insert "bla bla bla" if not then insert "bla2 bla2 bla2" where I currently have Content1. Anyone know how I can do this? thanks for your help.

echo "<table border='2' width='100%' bordercolor='#995961' ALIGN=CENTER BGCOLOR= '#ffd7a5'>";print "<br />";print "<tr><th colspan=3 align=center> <font size=5 color=maroon>PAYMENT HISTORY</th></tr></font><tr><th width='30%' align=center>Attribute Name<th width='33%'>Your Input</th><th>Risk Profile</th></tr><tr><td>Worst Credit Rating/Status on Any Active Line</td><td align=center >$StatusActive</td><td align=center >Content1</td></tr><tr><td>Worst Credit Rating/Status Ever (including closed)</td><td align=center >$StatusEver</td><td align=center >Content2</td></tr><tr><td>Total Number of 1 Missed Payment</td><td align=center >$Current1</td><td align=center >Content3</td></tr>";echo "</table>";

Link to comment
Share on other sites

If this is PHP, then just break up the HTML and echo it by pieces:

echo "<td>";if($Score > 300) {  echo "Value 1";} else {  echo "Value 2";}echo "</td>"

Link to comment
Share on other sites

Thanks, so I would put this in here?

<tr><td>Worst Credit Rating/Status on Any Active Line</td><td align=center >$StatusActive</td><td align=center > [color="#8B0000"]echo "<td>";if($Score > 300) {  echo "Value 1";} else {  echo "Value 2";}echo "</td>"[/color]</td></tr>

Link to comment
Share on other sites

Thanks, so I would put this in here?
<tr><td>Worst Credit Rating/Status on Any Active Line</td><td align=center >$StatusActive</td><td align=center > echo "<td>";if($Score > 300) {  echo "Value 1";} else {  echo "Value 2";}echo "</td>"</td></tr>

Link to comment
Share on other sites

Thanks, so I would put this in here?
<tr><td>Worst Credit Rating/Status on Any Active Line</td><td align=center >$StatusActive</td><td align=center > echo "<td>";if($Score > 300) {  echo "Value 1";} else {  echo "Value 2";}echo "</td>"</td></tr>

No, PHP code can't be placed inside a string, and you can't put a <td> element inside another <td> element.You have to close the string, write the code, and echo a new string after that.
 . . . . . .echo "<tr><td>Worst Credit Rating/Status on Any Active Line</td><td align=center >$StatusActive</td><td align=center >";if($Score > 300) {  echo "Value 1";} else {  echo "Value 2";}echo "</td></tr>"; . . . . . .

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...