Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2007
    Location
    Albany, Oregon
    Posts
    66
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Help with if statement

    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:

    PHP Code:
    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?

  • #2
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Try this

    PHP Code:
    $deadlineYear !=="Year" 

  • #3
    New Coder
    Join Date
    Feb 2007
    Location
    Albany, Oregon
    Posts
    66
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Great - that worked. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •