Jump to content

Simple else if statment


whojstall11

Recommended Posts

Im try to write an else statement in php where: if keyword is equal to letter or word it will give me an error message. right now my statement looks like this.

 

mysqli_stmt_close ($query);
            } else //problem with a query
              echo "Error: " . mysqli_error($conn);
          } else { //no keyword 
              echo "No keyword was specified";
          }else (keyword == "??") {
              echo "has to be a number";
          }
         
         
         mysqli_close($conn);
     }
?>
  </body>
</html>

 

Keyword is an int

Link to comment
https://forums.phpfreaks.com/topic/259256-simple-else-if-statment/
Share on other sites

it has to be in this format...

 

if(condition)
{
    //code block if condition is true
}
else
{
    //code block if condition is false
}

if you have multiple conditions...

if(condition1)
{
    //code block if condition1 is true
}
elseif(condition2)
{
    //code block if condition1 is false and condition 2 is true
}
else
{
     //code block if no condition above was true
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.