Re: If statement duplicating mysql records?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jun 21, 2007, at 1:58 PM, Roberto Mansfield wrote:

Jason Pruim wrote:

It's not quite making sense to me though... My understanding of IF
statements is if the condition is met it ignores all the other if's. Is that not correct? At this point it's just me trying to figure things out
for my knowledge :)

No, that's not how it works. If the condition is met, the contents of
the if block are executed. If not, and there is an ELSE block, those
commands are executed. Then, the script continues after the whole
if/then/else structure.

Maybe you are thinking of an IF/ELSEIF/ELSEIF/.../ELSE structure?

if ( $row[5] == "Level1" ) {
  // your commands

} elseif ( $row[5] == "Level2" ) {
  // your commands

} else {
  // your commands

}

This would work in the way you are thinking. Hope this helps your
understanding.


Hi Roberto,

Thanks for pointing that out, I think it looks better then having a bunch of related if statements with an else at the end anyway. :)

Always helps when you use the right tools for the job! :)


--
Roberto Mansfield
Institutional Research and Application Development (IRAD)
SAS Computing


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux