Computing.Net > Forums > Web Development > nested if else statements

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

nested if else statements

Reply to Message Icon

Name: BigShow
Date: October 14, 2008 at 20:45:32 Pacific
OS: xp
CPU/Ram: pentium 4
Product: dell
Comment:

Hey Guys, I was wondering if it is possible to have a nested if else statement wihin an ifelse statement, example

if (condition) {
if (condition) {
(statement)
} else {
(statement)
}
} else {
(statement)
}

Is this possible of is there a better way.



Sponsored Link
Ads by Google

Response Number 1
Name: CodyJoyce
Date: October 15, 2008 at 04:21:29 Pacific
Reply:

It is possible, and quite ok to use unless your going to be nesting again and again.

What language are you using?

-Cody Joyce
PHP Developer / Technician


0

Response Number 2
Name: BigShow
Date: October 15, 2008 at 05:57:50 Pacific
Reply:

Hey Cody,

I am using PHP. I wrote the code and I have checked it again and again but it still says there is an error.

Parse error: syntax error, unexpected T_ELSE

It is pointing to the last else statement. I will work with it to see what I can do. Any suggestions.


0

Response Number 3
Name: shutat
Date: October 15, 2008 at 09:33:52 Pacific
Reply:

It's probably a missing bracket somewhere, but it may be many lines above where the processor flags it. Check it by using a block comment to comment out code segments that you know are valid.

Depending on what you're doing, you may be able to use the switch in place of nested if-else if-else


0

Response Number 4
Name: BigShow
Date: October 15, 2008 at 10:10:34 Pacific
Reply:

Your right, it was a missing bracket on a small if statement I put in if the query was empty, didnt even see it.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Can any one help me on te... mp3 player tutorial



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: nested if else statements

Javascript form www.computing.net/answers/webdevel/javascript-form/2986.html

php question www.computing.net/answers/webdevel/php-question/483.html

Add minutes to this javascript! www.computing.net/answers/webdevel/add-minutes-to-this-javascript/2221.html