whojstall11 Posted March 19, 2012 Share Posted March 19, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/259256-simple-else-if-statment/ Share on other sites More sharing options...
smerny Posted March 20, 2012 Share Posted March 20, 2012 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 } Quote Link to comment https://forums.phpfreaks.com/topic/259256-simple-else-if-statment/#findComment-1329479 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.