Multiple "if()" statements
| From: | Grae Wolfe - PHP | Date: | Wed, 28 Jun 2006 23:38:09 +0000 |
| Subject: | Multiple "if()" statements | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-238870@lists.php.net to get a copy of this message | ||
I have a table with lots of fun information in it. For one of the pages
that I am working on, I want to display a list of names based on what is in
the DB.
My $SQL statement works great and has pulled in values for "first_name,"
"hs_last_name," and "last_name" in that order. Right now, I am just
printing to the screen the results of "first_name (hs_last_name) last_name"
but there are two problems with this...
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.
The following is the string of "IF()" statements that I am using, but I
have an issue with my syntax somewhere because it isn't working the way I
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>");