RE: [PHP] if/elseif being treated as if/if

2010-09-27 Thread Ford, Mike
-Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: 25 September 2010 16:02 One can make the argument that the ELSE IF statement first surfaced circa 1977 in FORTRAN 77 and the CASE statement came later in FORTRAN 90 circa 1991. Being a fully-fledged member of

RE: [PHP] if/elseif being treated as if/if

2010-09-27 Thread tedd
At 11:48 AM +0100 9/27/10, Ford, Mike wrote: -Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: 25 September 2010 16:02 One can make the argument that the ELSE IF statement first surfaced circa 1977 in FORTRAN 77 and the CASE statement came later in FORTRAN

RE: [PHP] if/elseif being treated as if/if

2010-09-25 Thread tedd
At 3:54 PM -0400 9/24/10, Bob McConnell wrote: From: tedd At 2:23 PM -0400 9/24/10, Bob McConnell wrote: A switch works when a single test can dispatch all possible branches. If you have a series of tests where each looks for a different subset of conditions, you need an elseif. Not

RE: [PHP] if/elseif being treated as if/if

2010-09-25 Thread tedd
At 9:04 PM +0100 9/24/10, Ashley Sheridan wrote: I don't often use this type of logic, but I have used it before and it's served me well. Essentially, a switch is a glorified if statement, and I find them a lot nicer to read and write than a series of if/elseif blocks. Thanks, Ash Ash:

[PHP] if/elseif being treated as if/if

2010-09-24 Thread Andy McKenzie
Hey folks, Here's the deal. I have the following code: if($col_vals[$i][$val['column']] == $search_result[0][$col]) { echo ' selected=selected'; } elseif($val['default'] == $col_vals[$i][$val['column']]) { echo ' selected=selected'; } It's supposed to check whether

Re: [PHP] if/elseif being treated as if/if

2010-09-24 Thread chris h
Andy I see no reason why both echo's would fire; unless this block of code gets executed multiple times. can we see more of the code? Chris H. On Fri, Sep 24, 2010 at 1:50 PM, Andy McKenzie amckenz...@gmail.com wrote: Hey folks, Here's the deal. I have the following code:

Re: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Marc Guay
if(1 == 1){ echo 'here'; } elseif(1 == 1){ echo 'here'; } Will only echo here once. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] if/elseif being treated as if/if

2010-09-24 Thread tedd
At 1:50 PM -0400 9/24/10, Andy McKenzie wrote: Hey folks, Here's the deal. I have the following code: if($col_vals[$i][$val['column']] == $search_result[0][$col]) { echo ' selected=selected'; } elseif($val['default'] == $col_vals[$i][$val['column']]) { echo '

RE: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Bob McConnell
From: tedd At 1:50 PM -0400 9/24/10, Andy McKenzie wrote: Hey folks, Here's the deal. I have the following code: if($col_vals[$i][$val['column']] == $search_result[0][$col]) { echo ' selected=selected'; } elseif($val['default'] == $col_vals[$i][$val['column']]) { echo

Re: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Andy McKenzie
I found the problem while I was copying the code over. The problem is that the if triggers in loop one, and the elseif triggers in loop two. In other words, it does exactly what it's supposed to, I just didn't think through what the loop would accomplish. Now to figure out how to make it do

RE: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Jay Blanchard
[snip] I am not in the majority when I say for conditions where you have more than two options use a switch control and not an elseif. In 40+ years of programming, I have never used elseif because the control confuses me. It is *much* easier for me to use, understand, and document a switch

RE: [PHP] if/elseif being treated as if/if

2010-09-24 Thread tedd
At 2:23 PM -0400 9/24/10, Bob McConnell wrote: A switch works when a single test can dispatch all possible branches. If you have a series of tests where each looks for a different subset of conditions, you need an elseif. Bob McConnell Bob: Not so, O'wise one. This will work: switch(1)

RE: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Steve Staples
this would be the same as: (commented below) On Fri, 2010-09-24 at 15:30 -0400, tedd wrote: At 2:23 PM -0400 9/24/10, Bob McConnell wrote: A switch works when a single test can dispatch all possible branches. If you have a series of tests where each looks for a different subset of

RE: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Bob McConnell
From: tedd At 2:23 PM -0400 9/24/10, Bob McConnell wrote: A switch works when a single test can dispatch all possible branches. If you have a series of tests where each looks for a different subset of conditions, you need an elseif. Not so, O'wise one. This will work: switch(1) {

RE: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Ashley Sheridan
On Fri, 2010-09-24 at 15:44 -0400, Steve Staples wrote: this would be the same as: (commented below) On Fri, 2010-09-24 at 15:30 -0400, tedd wrote: At 2:23 PM -0400 9/24/10, Bob McConnell wrote: A switch works when a single test can dispatch all possible branches. If you have a

RE: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Ashley Sheridan
On Fri, 2010-09-24 at 15:54 -0400, Bob McConnell wrote: From: tedd At 2:23 PM -0400 9/24/10, Bob McConnell wrote: A switch works when a single test can dispatch all possible branches. If you have a series of tests where each looks for a different subset of conditions, you need an

Re: [PHP] if/elseif being treated as if/if

2010-09-24 Thread Ashley Sheridan
On Fri, 2010-09-24 at 16:08 -0400, Joshua Kehn wrote: On Sep 24, 2010, at 4:04 PM, Ashley Sheridan wrote: On Fri, 2010-09-24 at 15:54 -0400, Bob McConnell wrote: From: tedd At 2:23 PM -0400 9/24/10, Bob McConnell wrote: A switch works when a single test can dispatch all