Jump to content

If Else Ans Elseif In A Table


podarum
 Share

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...