Page 1 of 1

if loops

Posted: Wed Mar 05, 2008 3:43 pm
by Todlerone
Hello everyone, as per protocol...thank-you in advance for help. Sorry if this questions is extremely NOOB. Can I use the loop expression:

Code: Select all

if ($row[6] !="CANC" or $row[6] !="R" or $row[6] !="R1"){
//something
}else{
//something
}
Thank-you

Re: if loops

Posted: Wed Mar 05, 2008 3:54 pm
by Zoxive
IF is not a loop, and you have a syntax error at the end of your conditional statement.

And having }elseif(){} is pointless, its like its not even there.

Re: if loops

Posted: Wed Mar 05, 2008 4:02 pm
by Todlerone
I know the elseif part, there is code for that, I'm more interested if the first part of the loop can proceed given the expression. Thank-you

Re: if loops

Posted: Wed Mar 05, 2008 4:32 pm
by Sekka
Your syntax is all wrong.

Code: Select all

if ($row[6] != "CANC" || $row[6] != "R" || $row[6] != "R1") {
    // Something
} else {
    // Something else
}

Re: if loops

Posted: Wed Mar 05, 2008 4:46 pm
by Todlerone
How would one proceed given the need to verify the control structure. Would I use a SWITCH loop with a called function (to complete the same block of code for each of the cases? I was hoping I could use a loop with the three conditions in the control structure. Basically I want the main big loop to start if my array at $row[6] doesn't equal "CANC, R or R1"

Thanks

Re: if loops

Posted: Wed Mar 05, 2008 4:48 pm
by Sekka
Basically I want the main big loop to start if my array at $row[6] doesn't equal "CANC, R or R1"
The IF statement I posted seems to accomplish that task easily.

Re: if loops

Posted: Wed Mar 05, 2008 4:52 pm
by Todlerone
Sekka wrote:
Basically I want the main big loop to start if my array at $row[6] doesn't equal "CANC, R or R1"
The IF statement I posted seems to accomplish that task easily.
Sorry Sekka, misunderstood your reply. Thank-you. I will give it a try. CHEERS :D