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
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) }
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.
Summary: I've send a further example to your email. It's a combination of text input and button input. The button function as a color picker. Text input is where the value of the color will be entered, via but...
Summary: Changes are in bold. I wrote it so that the hours are converted to minutes as well so that you don't have to compare two variables in the comparisons (so 90 would be 1:30am). Add as many if..else stat...