if loops

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

if loops

Post 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
Last edited by Todlerone on Wed Mar 05, 2008 4:50 pm, edited 4 times in total.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: if loops

Post 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.
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: if loops

Post 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
User avatar
Sekka
Forum Commoner
Posts: 91
Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK

Re: if loops

Post by Sekka »

Your syntax is all wrong.

Code: Select all

if ($row[6] != "CANC" || $row[6] != "R" || $row[6] != "R1") {
    // Something
} else {
    // Something else
}
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: if loops

Post 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
User avatar
Sekka
Forum Commoner
Posts: 91
Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK

Re: if loops

Post 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.
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: if loops

Post 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
Post Reply