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>");
  } else
     print("<tr>");
  print("<td>$row[0] ($row[1]) $row[2]</td>");
      print("</tr>");


Grae,

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];
        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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to