Re: If statement duplicating mysql records?

From: Date: Thu, 21 Jun 2007 18:28:26 +0000
Subject: Re: If statement duplicating mysql records?
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-257586@lists.php.net to get a copy of this message
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


« previous php.general (#257586) next »