On Wed, 2006-06-28 at 20:02, David Tulloh wrote: > Grae Wolfe - PHP wrote: > > ... > > want. Any help would be great! > > > > > > if($row[1]="none") { > > print("<tr>"); > > print("<td>$row[0] $row[2]</td>"); > > print("</tr>"); > > } else > > if($row[1]=$row[2]) { > > print("<tr>"); > > print("<td>$row[0] $row[2]</td>"); > > print("</tr>"); > > } else > > print("<tr>"); > > print("<td>$row[0] ($row[1]) $row[2]</td>"); > > print("</tr>"); > > > > Indenting is your friend, indented version of what you had. > > if($row[1]="none") { > print("<tr>"); > print("<td>$row[0] $row[2]</td>"); > print("</tr>"); > } else > if($row[1]=$row[2]) { > print("<tr>"); > print("<td>$row[0] $row[2]</td>"); > print("</tr>"); > } else > print("<tr>"); > print("<td>$row[0] ($row[1]) $row[2]</td>"); > print("</tr>"); > > The bigest problem with the above is that both the else becomes unclear > when they finish due to the lack of {}. > The ifs should also be using an == instead of an =, you want to compare > not assign. > > I'm also going to throw in an elseif for fun, to get this (hopefully) > improved version: > > if($row[1] == "none") { > print("<tr>"); > print("<td>$row[0] $row[2]</td>"); > print("</tr>"); > } elseif($row[1] == $row[2]) { > print("<tr>"); > print("<td>$row[0] $row[2]</td>"); > print("</tr>"); > } else { > print("<tr>"); > print("<td>$row[0] ($row[1]) $row[2]</td>"); > print("</tr>"); > } And for really clear code... if( $row[1] == "none ") { print( "<tr>" ); print( "<td>$row[0] $row[2]</td>" ); print( "</tr>" ); } else if( $row[1] == $row[2] ) { print( "<tr>" ); print( "<td>$row[0] $row[2]</td>" ); print( "</tr>"); } else { print( "<tr>" ); print( "<td>$row[0] ($row[1]) $row[2]</td>" ); print( "</tr>" ); } Now you know when you've forgotten an opening brace and it lines up beutifully vertically. Now I need to run and hide before a braces holy war erupts *Wheeeeeeeeeeeeeeeeeeeeeeeee*. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php