...

View Full Version : Help with if statement



zach4618
07-21-2007, 08:26 PM
I would like to display a table conditionally based on the input a user has submitted via a form. Part of the form asks the user to select a deadline month and year from a drop down. On the redirect page I display all the information that was just submitted.

What I want to do is add a row to the table for this information only if something was selected for the variables $deadlineMonth and $deadlineYear.

The default options selected from the drop downs are "Month" and "Year" so I do not want to display the row at all if this is the data received. Here is what I have so far:


if ($deadlineMonth=="Month" && $deadlineYear=="Year") {}

elseif ($deadlineMonth=="Month" && !$deadlineYear=="Year") {
echo "<tr>/n <td>Deadline:</td>/n <td>$deadlineYear</td>\n</tr>";}

elseif (!$deadlineMonth=="Month" && $deadlineYear=="Year") {
echo "<tr>/n <td>Deadline:</td>/n <td>$deadlineMonth</td>\n</tr>";}

else {
echo "<tr>/n <td>Deadline:</td>/n <td>$deadlineMonth $deadlineYear</td>\n</tr>";}

However I discovered that using this format: !$deadlineMonth=="Month" does not work. Anyone know how to fix this problem?

matak
07-21-2007, 09:23 PM
Try this


$deadlineYear !=="Year"

zach4618
07-21-2007, 09:46 PM
Great - that worked. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum