How to stop if statement with double results

Hi,
I have a simple if statement that would render the result just like this:


if (this->stuff) {
     do this stuff;
} elseif (that->stuff) {
     do that stuff;
}

It happens when I join two tables together. I knew that the query has possible 2 results, which straddled between this->stuff and that->stuff, but how do I stop at only the this->stuff process and not go to the else statement after the first if statement executed.

I hope I make myself clear with the question above.

Thanks for your help in advance,
Ket

$count = 0;
while ( /* condition goes here */) {
    $count++;
    if (this->stuff) {
        do this stuff;
    } elseif (that->stuff) {
        if ( $count >= 2 ) {
            continue;
        } else {
            do that stuff;
        }
    }
}

That will have it ignore the “do that” if the loop has already been run through at least once. If you want to ignore the “do that” after “do this” has been run once, then move the

$count++;

and change the $count check:

$count = 0;
while ( /* condition goes here */) {
    
    if (this->stuff) {
    $count++;    
        do this stuff;
    } elseif (that->stuff) {
        if ( $count >= 1 ) {
            continue;
        } else {
            do that stuff;
        }
    }
}

Hope that helps.

Thanks SpacePhoenix, Million Thanks

This works great.

Or a better query. That’d work too.

we can only speculate :cool:

StarLion is right too, better query works like a charm. Only it happens by accident. And before that accident happened, you would like to smash your head to a wall.

Good queries shouldn’t happen by accident. They should happen on purpose.
If they happen by accident, I guess some more study is needed :wink:

Ya, acidental queries puzzle me because the command had to come from some where. Studding is needed indeed.