Re: Multiple "if()" statements
| From: | Paul Novitski | Date: | Thu, 29 Jun 2006 00:17:52 +0000 |
| Subject: | Re: Multiple "if()" statements | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238877@lists.php.net to get a copy of this message | ||
At 04:38 PM 6/28/2006, Grae Wolfe - PHP wrote:
The first problem is men's names and unmarried women's names... they will have the same "hs_last_name" and "last_name" so I don't want the duplicate displaying on the page. The second problem is the entry of the word "none" by some of the visitors in place of a "hs_last_name"... obviously I don't want to display this either. 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>"); } elseGrae, For ease of maintenance, and to reduce repetition in the code, I would separate the logic of your string concatenation from the HTML output, something like this: $sName = $row[0];print("<tr>");print("<td>$row[0] ($row[1]) $row[2]</td>");print("</tr>");
if ($row[1] != "none" && $row[1] != $row[2]) $sName .= $row[1];$sName .= $row[2]; $sHTML = <<< hdHTML <tr>
<td>$sName</td></tr> hdHTML; print($sHTML); Regards, Paul